1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00

Ensure that iterating over each registered factory returns them uniquely

This commit is contained in:
Joshua Clayton 2011-06-30 18:26:06 -04:00
parent 2f41dc729e
commit d7feb60bf5
2 changed files with 14 additions and 1 deletions

View file

@ -16,7 +16,7 @@ module FactoryGirl
end
def each(&block)
@items.values.each(&block)
@items.values.uniq.each(&block)
end
def [](name)

View file

@ -50,6 +50,19 @@ describe FactoryGirl::Registry do
result.should =~ [factory, other_factory]
end
it "iterates registered factories uniquely with aliases" do
other_factory = FactoryGirl::Factory.new(:string, :aliases => [:awesome])
subject.add(factory)
subject.add(other_factory)
result = []
subject.each do |value|
result << value
end
result.should =~ [factory, other_factory]
end
it "registers an sequence" do
sequence = FactoryGirl::Sequence.new(:email) { |n| "somebody#{n}@example.com" }
subject.add(sequence)