1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot_rails.git synced 2022-11-09 11:49:18 -05:00

allow dir to be optional param for generator

[Fixes #131]
This commit is contained in:
Trevor John 2014-06-28 13:32:06 -04:00
parent 4defe4c666
commit d5a435dab0
2 changed files with 16 additions and 1 deletions

View file

@ -83,3 +83,18 @@ Feature:
Then the following files should not exist:
| test/factories/users.rb |
| spec/factories/users.rb |
Scenario: Use a suffix with the Factory Girl generator
When I add "rspec-rails" as a dependency
When I configure the factories as:
"""
config.generators do |g|
g.factory_girl suffix: 'suffix'
end
"""
And I run `bundle install` with a clean environment
And I run `bundle exec rails generate model User name:string` with a clean environment
Then the following files should exist:
| spec/factories/users_suffix.rb |
Then the following files should not exist:
| spec/factories/users.rb |

View file

@ -16,7 +16,7 @@ module FactoryGirlRails
end
def factory_girl_directory
@generators.options.fetch(:factory_girl, { dir: 'spec/factories' })[:dir]
@generators.options.fetch(:factory_girl, {}).fetch(:dir, 'spec/factories')
end
end
end