mirror of
https://github.com/thoughtbot/factory_bot_rails.git
synced 2022-11-09 11:49:18 -05:00
parent
3a050736f3
commit
c761d47c93
3 changed files with 26 additions and 2 deletions
|
@ -32,6 +32,23 @@ Feature:
|
|||
And the following files should not exist:
|
||||
| spec/fixtures/users.yml |
|
||||
|
||||
Scenario: Using Factory Girl and Factory Girl Rails with RSpec and suffix configuration should generate a factory file with suffix
|
||||
When I add "rspec-rails" as a dependency
|
||||
And I configure the factories as:
|
||||
"""
|
||||
config.generators do |g|
|
||||
g.test_framework :rspec, fixture: true
|
||||
g.fixture_replacement :factory_girl, suffix: 'factory'
|
||||
end
|
||||
"""
|
||||
And I run `bundle install` with a clean environment
|
||||
Then the output should contain "rspec-rails"
|
||||
And I run `bundle exec rails generate model User name:string` with a clean environment
|
||||
Then the following files should exist:
|
||||
| spec/factories/users_factory.rb |
|
||||
And the following files should not exist:
|
||||
| spec/fixtures/users.yml |
|
||||
|
||||
Scenario: Using Factory Girl and Factory Girl Rails does not override a manually-configured factories directory using RSpec
|
||||
When I add "rspec-rails" as a dependency
|
||||
And I configure the factories directory as "custom/dir"
|
||||
|
|
|
@ -65,7 +65,7 @@ Feature: automatically load step definitions
|
|||
When I write to "lib/some_railtie/factories.rb" with:
|
||||
"""
|
||||
FactoryGirl.define do
|
||||
factory :factory_from_some_railtie, :class => 'User' do
|
||||
factory :factory_from_some_railtie, class: 'User' do
|
||||
name 'Artem'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,13 @@ module FactoryGirl
|
|||
desc: "The directory or file root where factories belong"
|
||||
)
|
||||
|
||||
class_option(
|
||||
:suffix,
|
||||
type: :string,
|
||||
default: nil,
|
||||
desc: "Suffix to add factory file"
|
||||
)
|
||||
|
||||
def create_fixture_file
|
||||
if File.exist?(factories_file)
|
||||
insert_factory_into_existing_file
|
||||
|
@ -69,7 +76,7 @@ RUBY
|
|||
end
|
||||
|
||||
def filename_suffix
|
||||
factory_girl_options[:suffix]
|
||||
factory_girl_options[:suffix] || options[:suffix]
|
||||
end
|
||||
|
||||
def factory_girl_options
|
||||
|
|
Loading…
Reference in a new issue