2010-06-10 13:37:51 -04:00
|
|
|
require 'spec_helper'
|
2009-04-11 11:27:23 -04:00
|
|
|
|
2010-06-24 09:45:57 -04:00
|
|
|
describe FactoryGirl::Sequence do
|
2010-08-12 22:42:18 -04:00
|
|
|
describe "a basic sequence" do
|
2009-04-11 11:27:23 -04:00
|
|
|
before do
|
2010-06-24 09:45:57 -04:00
|
|
|
@sequence = FactoryGirl::Sequence.new {|n| "=#{n}" }
|
2009-04-11 11:27:23 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should start with a value of 1" do
|
|
|
|
@sequence.next.should == "=1"
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "after being called" do
|
|
|
|
before do
|
|
|
|
@sequence.next
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should use the next value" do
|
|
|
|
@sequence.next.should == "=2"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-08-12 22:42:18 -04:00
|
|
|
|
|
|
|
describe "a custom sequence" do
|
|
|
|
before do
|
|
|
|
@sequence = FactoryGirl::Sequence.new("A") {|n| "=#{n}" }
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should start with a value of A" do
|
|
|
|
@sequence.next.should == "=A"
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "after being called" do
|
|
|
|
before do
|
|
|
|
@sequence.next
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should use the next value" do
|
|
|
|
@sequence.next.should == "=B"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-04-11 11:27:23 -04:00
|
|
|
end
|