Sha256: 933e8bf4348ac8263f3378ab6dc4801908f01eaa36109f07c31e125acd0c22e2

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 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

    config.after_initialize do
      FactoryGirl.definition_file_paths = [
          File.join(Rails.root, 'factories'),
          File.join(Rails.root, 'test', 'factories'),
          File.join(Rails.root, 'spec', 'factories')
      ]
      FactoryGirl.find_definitions
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
factory_girl_rails-1.4.0 lib/factory_girl_rails/railtie.rb
factory_girl_rails-1.3.0 lib/factory_girl_rails/railtie.rb