2017-10-20 15:20:28 -04:00
|
|
|
Feature: FactoryBot can find factory definitions correctly
|
2011-07-22 11:38:56 -04:00
|
|
|
Scenario: Find definitions with a path
|
|
|
|
Given a file named "awesome_factories.rb" with:
|
|
|
|
"""
|
2017-10-20 15:20:28 -04:00
|
|
|
FactoryBot.define do
|
2011-07-29 12:22:29 -04:00
|
|
|
factory :awesome_category, :class => Category do
|
2018-07-29 11:30:02 -04:00
|
|
|
name { "awesome!!!" }
|
2011-07-22 11:38:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
"""
|
2017-10-20 15:20:28 -04:00
|
|
|
When "awesome_factories.rb" is added to FactoryBot's file definitions path
|
|
|
|
And I create a "awesome_category" instance from FactoryBot
|
2011-07-22 11:38:56 -04:00
|
|
|
Then I should find the following for the last category:
|
|
|
|
| name |
|
|
|
|
| awesome!!! |
|
|
|
|
|
2011-07-22 14:47:47 -04:00
|
|
|
Scenario: Find definitions with an absolute path
|
|
|
|
Given a file named "awesome_factories.rb" with:
|
|
|
|
"""
|
2017-10-20 15:20:28 -04:00
|
|
|
FactoryBot.define do
|
2011-07-29 12:22:29 -04:00
|
|
|
factory :another_awesome_category, :class => Category do
|
2018-07-29 11:30:02 -04:00
|
|
|
name { "awesome!!!" }
|
2011-07-22 14:47:47 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
"""
|
2017-10-20 15:20:28 -04:00
|
|
|
When "awesome_factories.rb" is added to FactoryBot's file definitions path as an absolute path
|
|
|
|
And I create a "another_awesome_category" instance from FactoryBot
|
2011-07-22 14:47:47 -04:00
|
|
|
Then I should find the following for the last category:
|
|
|
|
| name |
|
|
|
|
| awesome!!! |
|
|
|
|
|
2011-07-22 11:38:56 -04:00
|
|
|
Scenario: Find definitions with a folder
|
|
|
|
Given a file named "nested/great_factories.rb" with:
|
|
|
|
"""
|
2017-10-20 15:20:28 -04:00
|
|
|
FactoryBot.define do
|
2011-07-29 12:22:29 -04:00
|
|
|
factory :great_category, :class => Category do
|
2018-07-29 11:30:02 -04:00
|
|
|
name { "great!!!" }
|
2011-07-22 11:38:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
"""
|
2017-10-20 15:20:28 -04:00
|
|
|
When "nested" is added to FactoryBot's file definitions path
|
|
|
|
And I create a "great_category" instance from FactoryBot
|
2011-07-22 11:38:56 -04:00
|
|
|
Then I should find the following for the last category:
|
|
|
|
| name |
|
|
|
|
| great!!! |
|
2011-07-29 12:22:29 -04:00
|
|
|
|
2017-10-20 15:20:28 -04:00
|
|
|
Scenario: Reload FactoryBot
|
2011-09-02 14:41:38 -04:00
|
|
|
Given a file named "nested/reload_factories.rb" with:
|
2011-07-29 12:22:29 -04:00
|
|
|
"""
|
2017-10-20 15:20:28 -04:00
|
|
|
FactoryBot.define do
|
2011-09-02 14:41:38 -04:00
|
|
|
sequence(:great)
|
|
|
|
trait :admin do
|
2018-07-29 11:30:02 -04:00
|
|
|
admin { true }
|
2011-09-02 14:41:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :handy_category, :class => Category do
|
2018-07-29 11:30:02 -04:00
|
|
|
name { "handy" }
|
2011-07-29 12:22:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
"""
|
2017-10-20 15:20:28 -04:00
|
|
|
When "nested" is added to FactoryBot's file definitions path
|
2011-09-02 14:41:38 -04:00
|
|
|
And I append to "nested/reload_factories.rb" with:
|
|
|
|
"""
|
|
|
|
|
2017-10-20 15:20:28 -04:00
|
|
|
FactoryBot.modify do
|
2011-09-02 14:41:38 -04:00
|
|
|
factory :handy_category do
|
2018-07-29 11:30:02 -04:00
|
|
|
name { "HANDY!!!" }
|
2011-09-02 14:41:38 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
"""
|
|
|
|
And I reload factories
|
2017-10-20 15:20:28 -04:00
|
|
|
And I create a "handy_category" instance from FactoryBot
|
2011-07-29 12:22:29 -04:00
|
|
|
Then I should find the following for the last category:
|
|
|
|
| name |
|
2011-09-02 14:41:38 -04:00
|
|
|
| HANDY!!! |
|