Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Non-overriden parent dynamic methods should be assigned before the ch…

…ild's

Closes #173
  • Loading branch information...
commit 2ccbf4561bbf61e9faf83e88c68b987bc1461ebd 1 parent 4b83b1e
@twalpole twalpole authored joshuaclayton committed
Showing with 9 additions and 7 deletions.
  1. +1 −1  lib/factory_girl/factory.rb
  2. +8 −6 spec/acceptance/parent_spec.rb
View
2  lib/factory_girl/factory.rb
@@ -50,7 +50,7 @@ def inherit_from(parent) #:nodoc:
end
end
- @attributes += new_attributes
+ @attributes.unshift *new_attributes
@attributes.sort!
end
View
14 spec/acceptance/parent_spec.rb
@@ -3,7 +3,7 @@
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 @@
factory :admin do
name "admin"
admin true
+ upper_email { email.upcase }
end
factory :guest do
@@ -29,11 +30,12 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.