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,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
|
||||||
|
|
Loading…
Reference in a new issue