Permalink
Browse files

Fix vintage syntax and add spec for creating child factories with vin…

…tage syntax
  • Loading branch information...
1 parent 450dbb2 commit f8638b3085a51e438e5618554fff04e61692ac10 @joshuaclayton joshuaclayton committed Sep 23, 2011
Showing with 19 additions and 1 deletion.
  1. +1 −1 lib/factory_girl/syntax/vintage.rb
  2. +18 −0 spec/acceptance/syntax/vintage_spec.rb
View
2 lib/factory_girl/syntax/vintage.rb
@@ -29,7 +29,7 @@ def self.define(name, options = {})
proxy = FactoryGirl::DefinitionProxy.new(factory)
yield(proxy)
if parent = options.delete(:parent)
- factory.inherit_from(FactoryGirl.factory_by_name(parent))
+ factory.inherit_factory(FactoryGirl.factory_by_name(parent))
end
FactoryGirl.register_factory(factory)
end
View
18 spec/acceptance/syntax/vintage_spec.rb
@@ -214,3 +214,21 @@
end
end
+
+describe "a factory with a parent" do
+ before do
+ define_model("User", :username => :string)
+
+ Factory.define(:user) do |factory|
+ factory.username "awesome_username"
+ end
+
+ Factory.define(:boring_user, :parent => :user) do |factory|
+ factory.username "boring_username"
+ end
+ end
+
+ it "supports defining parents" do
+ Factory.build(:boring_user).username.should == "boring_username"
+ end
+end

0 comments on commit f8638b3

Please sign in to comment.