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:
parent
eae2079422
commit
517cc944b3
1 changed files with 27 additions and 0 deletions
|
@ -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
|
||||
|
@ -143,6 +148,28 @@ class IntegrationTest < Test::Unit::TestCase
|
|||
|
||||
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
|
||||
|
||||
setup do
|
||||
|
|
Loading…
Reference in a new issue