问题
My project lives here: https://github.com/jonesdeini/ICanHazSandvich
I'm getting setup using minitest-rails add I can't get the generators to generate the correct test templates.
from my application.rb:
config.generators do |g|
g.test_framework :mini_test, :spec => true, :fixture => false
end
even with "g.test_framework nil" I still get the same test templates generated:
Output:
rails g model Foo
invoke active_record
create db/migrate/20120827160129_create_foos.rb
create app/models/foo.rb
invoke test_unit
create test/unit/foo_test.rb
invoke factory_girl
create test/factories/foos.rb
Even with "rails g model Foo --spec" the same files are generated. I'm using rails 3.2.8 and ruby-1.9.3-p194
Thanks for you help!
Gemfile:
group :development, :test do
gem 'factory_girl_rails'
gem 'minitest-rails'
gem 'minitest-rails-capybara'
end
EDIT:
A pull request has been submitted for this issue https://github.com/thoughtbot/factory_girl_rails/pull/68
回答1:
The problem is the factory_girl_rails
gem. That railtie is assuming either rspec
or test_unit
, and its configuration is conflicting with your configuration. Here is how I would resolve this:
Change the dependency to the factory_girl
gem in your Gemfile
file:
group :development, :test do
gem 'factory_girl'
gem 'minitest-rails'
gem 'minitest-rails-capybara'
end
Configure your app to use FactoryGirl in your config/application.rb
file:
config.generators do |g|
g.test_framework :mini_test, spec: true, fixture: false,
fixture_replacement: :factory_girl
end
Well, that's not entirely true. How I would really resolve it is to remove FactoryGirl completely, but that's an answer to a different question...
回答2:
The problem of the factory_girl_rails
gem forcing the use of Test::Unit
has been fixed by the maintainers, however this has not yet filtered through to rubygems.org
.
If you update your Gemfile to contain:
group :development, :test do
gem 'factory_girl_rails', :git => "git://github.com/thoughtbot/factory_girl_rails.git"
end
it should all work nicely!
来源:https://stackoverflow.com/questions/12148611/rails-generators-not-generating-the-proper-test-templates