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:
parent
4d4c01d29e
commit
854204dd12
1 changed files with 24 additions and 5 deletions
|
@ -19,14 +19,33 @@ 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
|
||||||
|
|
||||||
subject { FactoryGirl.build(:child_model) }
|
context "factory with a parent" do
|
||||||
|
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
|
||||||
subject[:evaluates_first].should == 1
|
subject[:evaluates_first].should == 1
|
||||||
subject[:evaluates_second].should == 1
|
subject[:evaluates_second].should == 1
|
||||||
subject[:evaluates_third].should == 1
|
subject[:evaluates_third].should == 1
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue