Add Registry#empty? to check if a registry has any items

This commit is contained in:
Seth Vargo 2014-10-23 11:24:13 -04:00
parent 2b03838fba
commit c0b107ff69
2 changed files with 18 additions and 0 deletions

View File

@ -59,6 +59,13 @@ module Vagrant
end
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
# registry. Note that the result cache is completely busted, so
# any gets on the new registry will result in a cache miss.

View File

@ -116,6 +116,17 @@ describe Vagrant::Registry do
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
it "should merge in another registry" do
one = described_class.new