1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot_rails.git synced 2022-11-09 11:49:18 -05:00

Initial support for MiniTest

Closes #68, #75
This commit is contained in:
Joshua Clayton 2012-12-10 11:29:57 -05:00
parent b59a4c51b0
commit bcbdc4558c
3 changed files with 45 additions and 10 deletions

View file

@ -41,12 +41,34 @@ Feature:
But the following files should exist: But the following files should exist:
| custom/dir/users.rb | | custom/dir/users.rb |
Scenario: Using Factory Girl and Factory Girl Rails does not override a manually-configured factories directory using Test::Unit 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" When I configure the factories directory as "custom/dir"
And I successfully run `bundle install` And I successfully run `bundle install`
And I successfully run `bundle exec rails generate model User name:string` And I successfully run `bundle exec rails generate model User name:string`
Then the following files should not exist: Then the following files should not exist:
| test/factories/users.rb | | test/factories/users.rb |
| spec/factories/users.rb | | spec/factories/users.rb |
But the following files should exist: But the following files should exist:
| custom/dir/users.rb | | 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"

View file

@ -28,3 +28,16 @@ class Testapp::Application
end end
END 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

View file

@ -13,7 +13,7 @@ module FactoryGirl
generators.fixture_replacement :factory_girl, :dir => 'spec/factories' generators.fixture_replacement :factory_girl, :dir => 'spec/factories'
end end
else 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
end end