Make sure to include the following in your rails_helper.rb:
config.include FactoryBot::Syntax::Methods
And change use_transactional_fixtures to false so we tell rspec we're using factories instead of fixtures:
config.use_transactional_fixtures = false
If you get the error Factory not registered make sure to include the following in your spec_helper.rb:
config.before(:all) do
FactoryBot.reload
end
Posted by hashharvest to Rails CheatSheets (2017-11-21 09:26)