From 517cc944b3a70ee0b003d8330e3dbb54819156c7 Mon Sep 17 00:00:00 2001 From: eugenebolshakov Date: Wed, 7 Jan 2009 12:17:14 -0500 Subject: [PATCH] Intergration test for inheritance --- test/integration_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/integration_test.rb b/test/integration_test.rb index 6b85c86..8c94368 100644 --- a/test/integration_test.rb +++ b/test/integration_test.rb @@ -23,6 +23,11 @@ class IntegrationTest < Test::Unit::TestCase f.email { Factory.next(:email) } end + Factory.define :guest, :parent => :user do |f| + f.last_name 'Anonymous' + f.username 'GuestUser' + end + Factory.sequence :email do |n| "somebody#{n}@example.com" end @@ -142,6 +147,28 @@ class IntegrationTest < Test::Unit::TestCase end end + + context "an instance generated by a factory that inherits from another factory" do + setup do + @instance = Factory.create(:guest) + end + + should "use the class name of the parent factory" do + assert_kind_of User, @instance + end + + should "have attributes of the parent" do + assert_equal 'Jimi', @instance.first_name + end + + should "have attributes defined in the factory itself" do + assert_equal 'GuestUser', @instance.username + end + + should "have attributes that have been overriden" do + assert_equal 'Anonymous', @instance.last_name + end + end context "an attribute generated by a sequence" do