diff --git a/features/fixture_replacement_config.feature b/features/fixture_replacement_config.feature index fbd99ae..d86a78a 100644 --- a/features/fixture_replacement_config.feature +++ b/features/fixture_replacement_config.feature @@ -41,12 +41,34 @@ Feature: But the following files should exist: | custom/dir/users.rb | - Scenario: Using Factory Girl and Factory Girl Rails does not override a manually-configured factories directory using Test::Unit - When I configure the factories directory as "custom/dir" - And I successfully run `bundle install` - And I successfully run `bundle exec rails generate model User name:string` - Then the following files should not exist: - | test/factories/users.rb | - | spec/factories/users.rb | - But the following files should exist: - | custom/dir/users.rb | + Scenario: Using Factory Girl and Factory Girl Rails does not override a manually-configured factories directory using Test::Unit + When I configure the factories directory as "custom/dir" + And I successfully run `bundle install` + And I successfully run `bundle exec rails generate model User name:string` + Then the following files should not exist: + | test/factories/users.rb | + | spec/factories/users.rb | + But the following files should exist: + | custom/dir/users.rb | + + Scenario: Using Factory Girl and Factory Girl Rails with MiniTest should generate a factory file + When I add "minitest" as a dependency + And I configure the testing framework to use MiniTest + And I successfully run `bundle install` + And I successfully run `bundle exec rails generate model User name:string` + Then the following files should exist: + | test/factories/users.rb | + But the following files should not exist: + | spec/fixtures/users.yml | + + Scenario: Using Factory Girl and Factory Girl Rails with MiniTest and a custom directory should generate a factory file + When I configure the factories directory as "custom/dir" + And I add "minitest" as a dependency + And I configure the testing framework to use MiniTest + And I successfully run `bundle install` + And I successfully run `bundle exec rails generate model User name:string` + Then the following files should exist: + | custom/dir/users.rb | + But the following files should not exist: + | spec/fixtures/users.yml | + And the file "test/models/user_test.rb" should contain "MiniTest::Rails::ActiveSupport::TestCase" diff --git a/features/step_definitions/rails_steps.rb b/features/step_definitions/rails_steps.rb index d7fb02b..09446fe 100644 --- a/features/step_definitions/rails_steps.rb +++ b/features/step_definitions/rails_steps.rb @@ -28,3 +28,16 @@ class Testapp::Application end END end + +When /^I configure the testing framework to use MiniTest$/ do + append_to_file('Gemfile', %{gem "minitest-rails", :group => [:development, :test]\n}) + step %{I successfully run `rails generate mini_test:install`} + + append_to_file File.join('config', 'application.rb'), <<-END +class Testapp::Application + config.generators do |g| + g.test_framework :mini_test, :fixture => false, :fixture_replacement => :factory_girl + end +end + END +end diff --git a/lib/factory_girl_rails/railtie.rb b/lib/factory_girl_rails/railtie.rb index 56648d1..62839b1 100644 --- a/lib/factory_girl_rails/railtie.rb +++ b/lib/factory_girl_rails/railtie.rb @@ -13,7 +13,7 @@ class Railtie < Rails::Railtie generators.fixture_replacement :factory_girl, :dir => 'spec/factories' end else - generators.test_framework :test_unit, :fixture => false, :fixture_replacement => :factory_girl + generators.test_framework rails_options[:test_framework], :fixture => false, :fixture_replacement => :factory_girl end end