Rails generators not generating the proper test templates

耗尽温柔 提交于 2019-12-06 12:13:48

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...

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!