thoughtbot/factory_girl — pull request #332 by kristianmandrup (2012-03-29 14:29:25+00:00)
Title: sequence can now have multiple aliases

$ bspec spec/factory_girl/
..........................................................................................................................................................................................................................................

Finished in 1.28 seconds
234 examples, 0 failures

Summary of changes and specs:
Note that in my first commit, the #sequences method needs a small fix (as shown below - fix has been tested)

subject { FactoryGirl::Sequence.new(name, :alias, :other, value) {|n| "=#{n}" } }

its(:name) { should == name }
its(:value) { should == value }
its(:names) { should == ([name] + aliases) }
its(:next) { should == "=3" }

def sequences(*names, &block)
FactoryGirl.register_sequence(Sequence.new(names, &block))
end

describe FactoryGirl::Registry do
let(:aliases) { [:thing, :widget] }
let(:sequence) { FactoryGirl::Sequence.new(:email) { |n| "somebody#{n}@example.com" } }
let(:sequences) { FactoryGirl::Sequence.new(:email, :sender, :receiver) { |n| "some_one_else#{n}@example.com" } }

it "registers a multi sequences" do
subject.add(sequences)
subject.find(:email).should == sequences
subject.find(:sender).should == sequences
subject.find(:receiver).should == sequences
end