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::Attribute::Association do
|
2011-11-22 18:01:01 -05:00
|
|
|
let(:name) { :author }
|
|
|
|
let(:factory) { :user }
|
2012-03-09 17:20:38 -05:00
|
|
|
let(:overrides) { { first_name: "John" } }
|
2011-11-22 18:01:01 -05:00
|
|
|
let(:association) { stub("association") }
|
2009-04-11 11:27:23 -04:00
|
|
|
|
2011-11-29 15:20:08 -05: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
|
|
|
|
2011-11-22 18:01:01 -05:00
|
|
|
it { should be_association }
|
2013-01-18 13:27:57 -05:00
|
|
|
its(:name) { should eq name }
|
2011-05-19 10:56:45 -04:00
|
|
|
|
2011-11-22 18:01:01 -05:00
|
|
|
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
|
2011-11-22 18:01:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "builds the association when calling the proc" do
|
2011-11-29 15:20:08 -05:00
|
|
|
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
|
2011-08-13 01:03:12 -04:00
|
|
|
end
|
2009-04-11 11:27:23 -04:00
|
|
|
|
2011-08-13 01:03:12 -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
|