allow factories to use all ancestors' traits
This commit is contained in:
parent
2bef7b142a
commit
f14a8cf215
|
@ -87,8 +87,8 @@ module FactoryGirl
|
||||||
|
|
||||||
def compile
|
def compile
|
||||||
unless @compiled
|
unless @compiled
|
||||||
parent.defined_traits.each {|trait| define_trait(trait) }
|
|
||||||
parent.compile
|
parent.compile
|
||||||
|
parent.defined_traits.each {|trait| define_trait(trait) }
|
||||||
@definition.compile
|
@definition.compile
|
||||||
@compiled = true
|
@compiled = true
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,6 +60,10 @@ describe "an instance generated by a factory with multiple traits" do
|
||||||
name "Judy"
|
name "Judy"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory :female_great_user do
|
||||||
|
great
|
||||||
|
end
|
||||||
|
|
||||||
factory :female_admin_judy, :traits => [:admin]
|
factory :female_admin_judy, :traits => [:admin]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -167,6 +171,11 @@ describe "an instance generated by a factory with multiple traits" do
|
||||||
subject { FactoryGirl.create(:user_without_admin_scoping) }
|
subject { FactoryGirl.create(:user_without_admin_scoping) }
|
||||||
it { expect { subject }.to raise_error(ArgumentError, "Trait not registered: admin_trait") }
|
it { expect { subject }.to raise_error(ArgumentError, "Trait not registered: admin_trait") }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "child factory using grandparents' trait" do
|
||||||
|
subject { FactoryGirl.create(:female_great_user) }
|
||||||
|
its(:great) { should == "GREAT!!!" }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "traits with callbacks" do
|
describe "traits with callbacks" do
|
||||||
|
|
Loading…
Reference in New Issue