Skip to content

Commit

Permalink
Initial support for MiniTest
Browse files Browse the repository at this point in the history
Closes #68, #75
  • Loading branch information
joshuaclayton committed Dec 10, 2012
1 parent b59a4c5 commit bcbdc45
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
40 changes: 31 additions & 9 deletions features/fixture_replacement_config.feature
Expand Up @@ -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"
13 changes: 13 additions & 0 deletions features/step_definitions/rails_steps.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/factory_girl_rails/railtie.rb
Expand Up @@ -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

Expand Down

0 comments on commit bcbdc45

Please sign in to comment.