1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/features/find_definitions.feature
Daniel Colson bf04aaa068 Autocorrect all static attributes to dynamic
Most of this was fixed by adding the `attribute-defined-statically-cop`
branch of `thoughtbot/rubocop-rspec` to the Gemfile and running:

```sh
  rubocop \
    --require rubocop-rspec \
    --only FactoryBot/AttributeDefinedStatically \
    --auto-correct
```

I had to update the cucumber tests manually, and I realized our changes
don't handle `ignore` blocks or blocks with arity 1 that use the yielded
DefinitionProxy. I will update
https://github.com/rubocop-hq/rubocop-rspec/pull/666to handle these
cases.
2018-09-14 19:27:13 +00:00

75 lines
2.2 KiB
Gherkin

Feature: FactoryBot can find factory definitions correctly
Scenario: Find definitions with a path
Given a file named "awesome_factories.rb" with:
"""
FactoryBot.define do
factory :awesome_category, :class => Category do
name { "awesome!!!" }
end
end
"""
When "awesome_factories.rb" is added to FactoryBot's file definitions path
And I create a "awesome_category" instance from FactoryBot
Then I should find the following for the last category:
| name |
| awesome!!! |
Scenario: Find definitions with an absolute path
Given a file named "awesome_factories.rb" with:
"""
FactoryBot.define do
factory :another_awesome_category, :class => Category do
name { "awesome!!!" }
end
end
"""
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
Then I should find the following for the last category:
| name |
| awesome!!! |
Scenario: Find definitions with a folder
Given a file named "nested/great_factories.rb" with:
"""
FactoryBot.define do
factory :great_category, :class => Category do
name { "great!!!" }
end
end
"""
When "nested" is added to FactoryBot's file definitions path
And I create a "great_category" instance from FactoryBot
Then I should find the following for the last category:
| name |
| great!!! |
Scenario: Reload FactoryBot
Given a file named "nested/reload_factories.rb" with:
"""
FactoryBot.define do
sequence(:great)
trait :admin do
admin { true }
end
factory :handy_category, :class => Category do
name { "handy" }
end
end
"""
When "nested" is added to FactoryBot's file definitions path
And I append to "nested/reload_factories.rb" with:
"""
FactoryBot.modify do
factory :handy_category do
name { "HANDY!!!" }
end
end
"""
And I reload factories
And I create a "handy_category" instance from FactoryBot
Then I should find the following for the last category:
| name |
| HANDY!!! |