2013-10-25 15:50:58 -04:00
|
|
|
describe "create multiple instances" do
|
|
|
|
before do
|
2018-10-07 21:45:51 -04:00
|
|
|
define_model("Post", title: :string, position: :integer)
|
2013-10-25 15:50:58 -04:00
|
|
|
|
2017-10-20 15:20:28 -04:00
|
|
|
FactoryBot.define do
|
2013-10-25 15:50:58 -04:00
|
|
|
factory(:post) do |post|
|
2018-07-29 11:30:02 -04:00
|
|
|
post.title { "Through the Looking Glass" }
|
2013-10-25 15:50:58 -04:00
|
|
|
post.position { rand(10**4) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "without default attributes" do
|
2017-10-20 15:20:28 -04:00
|
|
|
subject { FactoryBot.create_pair(:post) }
|
2013-10-25 15:50:58 -04:00
|
|
|
|
|
|
|
its(:length) { should eq 2 }
|
|
|
|
|
|
|
|
it "creates all the posts" do
|
|
|
|
subject.each do |record|
|
|
|
|
expect(record).not_to be_new_record
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "uses the default factory values" do
|
|
|
|
subject.each do |record|
|
|
|
|
expect(record.title).to eq "Through the Looking Glass"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|