Permalink
Browse files

Intergration test for inheritance

  • Loading branch information...
eugenebolshakov authored and jferris committed Jan 7, 2009
1 parent eae2079 commit 517cc944b3a70ee0b003d8330e3dbb54819156c7
Showing with 27 additions and 0 deletions.
  1. +27 −0 test/integration_test.rb
View
@@ -23,6 +23,11 @@ def setup
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 @@ def teardown
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

0 comments on commit 517cc94

Please sign in to comment.