Reputation: 51
I'm using rspec with factory_girl but when I run
rails g rspec:model catalog/product_type
I get this:
create spec/models/catalog/product_type_spec.rb
invoke factory_girl
create spec/factories/catalog_product_type.rb
but factory_girl doesn't generate the file in the catalog folder, instead it set catalog has part of the file name so I want to generate the factory_girl file just like it is generated in the spec file
Insted of this:
create spec/factories/catalog_product_type.rb
I want this
create spec/factories/catalog/product_type.rb
Upvotes: 1
Views: 883
Reputation: 11245
You can specify the default directory for your factories in your development.rb
configuration file:
config.generators do |g|
g.factory_girl dir: 'spec/factories/catalog/'
end
config.generators
is part of Rails can is a common pattern for defining generator paths for other gems/libraries as well.
For more options on FactoryGirl generator config you can see the source here:
And the docs:
https://github.com/thoughtbot/factory_girl_rails#configuration
Upvotes: 2