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

Non-overriden parent dynamic methods should be assigned before the child's

Closes #173
This commit is contained in:
Thomas Walpole 2011-08-08 15:59:48 -07:00 committed by Joshua Clayton
parent 4b83b1e62e
commit 2ccbf4561b
2 changed files with 9 additions and 7 deletions

View file

@ -50,7 +50,7 @@ module FactoryGirl
end
end
@attributes += new_attributes
@attributes.unshift *new_attributes
@attributes.sort!
end

View file

@ -3,7 +3,7 @@ require 'acceptance/acceptance_helper'
describe "an instance generated by a factory that inherits from another factory" do
before do
define_model("User", :name => :string, :admin => :boolean, :email => :string)
define_model("User", :name => :string, :admin => :boolean, :email => :string, :upper_email => :string)
FactoryGirl.define do
factory :user do
@ -13,6 +13,7 @@ describe "an instance generated by a factory that inherits from another factory"
factory :admin do
name "admin"
admin true
upper_email { email.upcase }
end
factory :guest do
@ -29,11 +30,12 @@ describe "an instance generated by a factory that inherits from another factory"
end
describe "the child class redefining parent's static method used by a dynamic method" do
subject { FactoryGirl.create(:admin) }
it { should be_kind_of(User) }
it { should be_admin }
its(:name) { should == "admin" }
its(:email) { should == "admin@example.com" }
subject { FactoryGirl.create(:admin) }
it { should be_kind_of(User) }
it { should be_admin }
its(:name) { should == "admin" }
its(:email) { should == "admin@example.com" }
its(:upper_email) { should == "ADMIN@EXAMPLE.COM"}
end
describe "the child class redefining parent's dynamic method" do