Sha256: 73bfda5bd5ef2a7d4dfbb530ff13679f75a331abf42b4a708c335c582760d02b

Contents?: true

Size: 877 Bytes

Versions: 23

Compression:

Stored size: 877 Bytes

Contents

require 'factory_girl'
require 'rails'

module FactoryGirl
  class Railtie < Rails::Railtie

    initializer "factory_girl.set_fixture_replacement" do
      generators = config.respond_to?(:app_generators) ? config.app_generators : config.generators

      if generators.options[:rails][:test_framework] == :rspec
        generators.fixture_replacement :factory_girl, :dir => 'spec/factories'
      else
        generators.test_framework :test_unit, :fixture => false, :fixture_replacement => :factory_girl
      end
    end

    initializer "factory_girl.set_factory_paths" do
      FactoryGirl.definition_file_paths = [
          File.join(Rails.root, 'factories'),
          File.join(Rails.root, 'test', 'factories'),
          File.join(Rails.root, 'spec', 'factories')
      ]
    end

    config.after_initialize do
      FactoryGirl.find_definitions
    end
  end
end

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
factory_girl_rails-1.7.0 lib/factory_girl_rails/railtie.rb
factory_girl_rails-1.6.0 lib/factory_girl_rails/railtie.rb
factory_girl_rails-1.5.0 lib/factory_girl_rails/railtie.rb