Permalink
Browse files

Ensure traits and dynamic attributes that are applied evaluate correctly

Closes #247
  • Loading branch information...
1 parent fba6f33 commit 1eb7e1bcc595692d8ee4d1bbd9b5af3ac477bdc6 @joshuaclayton joshuaclayton committed Nov 23, 2011
Showing with 23 additions and 0 deletions.
  1. +23 −0 spec/acceptance/traits_spec.rb
@@ -263,3 +263,26 @@
its(:name) { should == "Jack" }
end
end
+
+describe "traits and dynamic attributes that are applied simultaneously" do
+ before do
+ define_model("User", :name => :string, :email => :string, :combined => :string)
+
+ FactoryGirl.define do
+ trait :email do
+ email { "#{name}@example.com" }
+ end
+
+ factory :user do
+ name "John"
+ email
+ combined { "#{name} <#{email}>" }
+ end
+ end
+ end
+
+ subject { FactoryGirl.build(:user) }
+ its(:name) { should == "John" }
+ its(:email) { should == "John@example.com" }
+ its(:combined) { should == "John <John@example.com>" }
+end

0 comments on commit 1eb7e1b

Please sign in to comment.