I'm trying to use FactoryGirl gem inside my App in development mode (it's for mailer tests more) with rails_email_preview gem.
It works but only on initial page load, after reloading/refreshing the page I get following error:
Factory not registered: order
where order
is name of factory.
Here is my code (it is a dummy app for my Rails Engine):
spec/dummy/app/mailer_previews/mymodule/order_mailer_preview.rb
Dir[Mymodule::Core::Engine.root.join('spec', 'factories', '*')].each do |f|
require_dependency f
end
module Mymodule
class OrderMailerPreview
def confirmation_email
o = FactoryGirl.create(:order)
OrderMailer.confirmation_email(o)
end
end
end
Of course my factories works without any problem in test environment.
Any help would be appreciated.
EDIT:
p FactoryGirl.factories
returns (after page reload)
#<FactoryGirl::Registry:0x007ff2c9dd29d0 @name="Factory", @items={}>
Factory no registered
error. – Fatimafatimah