1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/spec/factory_girl/sequence_spec.rb
2012-03-16 13:17:15 -04:00

47 lines
1.2 KiB
Ruby

require 'spec_helper'
describe FactoryGirl::Sequence do
describe "a basic sequence" do
let(:name) { :test }
subject { FactoryGirl::Sequence.new(name) {|n| "=#{n}" } }
its(:name) { should == name }
its(:names) { should == [name] }
its(:next) { should == "=1" }
describe "when incrementing" do
before { subject.next }
its(:next) { should == "=2" }
end
end
describe "a custom sequence" do
subject { FactoryGirl::Sequence.new(:name, "A") {|n| "=#{n}" } }
its(:next) { should == "=A" }
describe "when incrementing" do
before { subject.next }
its(:next) { should == "=B" }
end
end
describe "a basic sequence without a block" do
subject { FactoryGirl::Sequence.new(:name) }
its(:next) { should == 1 }
describe "when incrementing" do
before { subject.next }
its(:next) { should == 2 }
end
end
describe "a custom sequence without a block" do
subject { FactoryGirl::Sequence.new(:name, "A") }
its(:next) { should == "A" }
describe "when incrementing" do
before { subject.next }
its(:next) { should == "B" }
end
end
end