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/attribute/association_spec.rb

29 lines
895 B
Ruby
Raw Normal View History

require 'spec_helper'
2009-04-11 11:27:23 -04:00
describe FactoryGirl::Attribute::Association do
let(:name) { :author }
let(:factory) { :user }
2012-03-09 17:20:38 -05:00
let(:overrides) { { first_name: "John" } }
let(:association) { stub("association") }
2009-04-11 11:27:23 -04:00
subject { FactoryGirl::Attribute::Association.new(name, factory, overrides) }
2012-03-09 17:20:38 -05:00
before { subject.stubs(association: association) }
2009-04-11 11:27:23 -04:00
it { should be_association }
2013-01-18 13:27:57 -05:00
its(:name) { should eq name }
it "builds the association when calling the proc" do
2013-01-18 13:27:57 -05:00
expect(subject.to_proc.call).to eq association
end
it "builds the association when calling the proc" do
subject.to_proc.call
2013-01-18 13:27:57 -05:00
expect(subject).to have_received(:association).with(factory, overrides)
2009-04-11 11:27:23 -04:00
end
end
2009-04-11 11:27:23 -04:00
describe FactoryGirl::Attribute::Association, "with a string name" do
subject { FactoryGirl::Attribute::Association.new("name", :user, {}) }
2013-01-18 13:27:57 -05:00
its(:name) { should eq :name }
2009-04-11 11:27:23 -04:00
end