mirror of
https://github.com/thoughtbot/factory_bot_rails.git
synced 2022-11-09 11:49:18 -05:00
b44b6b106b
Closes #120
28 lines
661 B
Ruby
28 lines
661 B
Ruby
require 'factory_girl'
|
|
require 'factory_girl_rails/generator'
|
|
require 'rails'
|
|
|
|
module FactoryGirl
|
|
class Railtie < Rails::Railtie
|
|
|
|
initializer "factory_girl.set_fixture_replacement" do
|
|
FactoryGirlRails::Generator.new(config).run
|
|
end
|
|
|
|
initializer "factory_girl.set_factory_paths" do
|
|
FactoryGirl.definition_file_paths = [
|
|
Rails.root.join('factories'),
|
|
Rails.root.join('test', 'factories'),
|
|
Rails.root.join('spec', 'factories')
|
|
]
|
|
end
|
|
|
|
config.after_initialize do
|
|
FactoryGirl.find_definitions
|
|
|
|
if defined?(Spring)
|
|
Spring.after_fork { FactoryGirl.reload }
|
|
end
|
|
end
|
|
end
|
|
end
|