1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00

Intergration test for inheritance

This commit is contained in:
eugenebolshakov 2009-01-07 12:17:14 -05:00 committed by Joe Ferris
parent eae2079422
commit 517cc944b3

View file

@ -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