Add Registry#empty? to check if a registry has any items
This commit is contained in:
parent
2b03838fba
commit
c0b107ff69
|
@ -59,6 +59,13 @@ module Vagrant
|
||||||
end
|
end
|
||||||
alias_method :size, :length
|
alias_method :size, :length
|
||||||
|
|
||||||
|
# Checks if this registry has any items.
|
||||||
|
#
|
||||||
|
# @return [Boolean]
|
||||||
|
def empty?
|
||||||
|
@items.keys.empty?
|
||||||
|
end
|
||||||
|
|
||||||
# Merge one registry with another and return a completely new
|
# Merge one registry with another and return a completely new
|
||||||
# registry. Note that the result cache is completely busted, so
|
# registry. Note that the result cache is completely busted, so
|
||||||
# any gets on the new registry will result in a cache miss.
|
# any gets on the new registry will result in a cache miss.
|
||||||
|
|
|
@ -116,6 +116,17 @@ describe Vagrant::Registry do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#empty" do
|
||||||
|
it "should return true when the registry is empty" do
|
||||||
|
expect(instance.empty?).to be(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return false when there is at least one element" do
|
||||||
|
instance.register("foo") { }
|
||||||
|
expect(instance.empty?).to be(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "merging" do
|
describe "merging" do
|
||||||
it "should merge in another registry" do
|
it "should merge in another registry" do
|
||||||
one = described_class.new
|
one = described_class.new
|
||||||
|
|
Loading…
Reference in New Issue