1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00

Ensure factories prioritize static attributes in all cases

This commit is contained in:
Thomas Walpole 2011-08-12 15:07:40 -07:00 committed by Joshua Clayton
parent 4d4c01d29e
commit 854204dd12

View file

@ -19,9 +19,17 @@ describe "a generated attributes hash where order matters" do
static 1 static 1
end end
end end
factory :without_parent, :class => ParentModel do
evaluates_first { static }
evaluates_second { evaluates_first }
evaluates_third { evaluates_second }
static 1
end
end end
end end
context "factory with a parent" do
subject { FactoryGirl.build(:child_model) } subject { FactoryGirl.build(:child_model) }
it "assigns attributes in the order they're defined with preference to static attributes" do it "assigns attributes in the order they're defined with preference to static attributes" do
@ -30,3 +38,14 @@ describe "a generated attributes hash where order matters" do
subject[:evaluates_third].should == 1 subject[:evaluates_third].should == 1
end end
end end
context "factory without a parent" do
subject { FactoryGirl.build(:without_parent) }
it "assigns attributes in the order they're defined with preference to static attributes without a parent class" do
subject[:evaluates_first].should == 1
subject[:evaluates_second].should == 1
subject[:evaluates_third].should == 1
end
end
end