I am trying to generate a new factory inside a module and I basically required
require 'rails/generators'
and I am calling the command below. Notice that it creates the file inside the test folder.
Rails::Generators.invoke 'factory_girl:model', ["Audit"]
-- create_table("audit", {:id=>:integer})
-> 0.0085s
create test/factories/audit.rb
When I try to generate the factory in the terminal, it creates the factory inside the spec folder:
vo@so:~/Desktop/ruby-pos/api$ rails generate factory_girl:model 'Audit'
create spec/factories/audits.rb
My problem is: I basically want to create the factory inside the spec folder when I run Rails::Generators.invoke 'factory_girl:model', ["Audit"]
.
I have been stuck in this problem for a few hours and that's why I am here :) Any ideas?
g.fixture_replacement :factory_bot, dir: 'spec/factories'
– Vizierate