diff --git a/features/fixture_replacement_config.feature b/features/fixture_replacement_config.feature index 671a643..b50ec12 100644 --- a/features/fixture_replacement_config.feature +++ b/features/fixture_replacement_config.feature @@ -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 | diff --git a/lib/factory_girl_rails/generators/rspec_generator.rb b/lib/factory_girl_rails/generators/rspec_generator.rb index 0248337..dd3fc29 100644 --- a/lib/factory_girl_rails/generators/rspec_generator.rb +++ b/lib/factory_girl_rails/generators/rspec_generator.rb @@ -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