繁体   English   中英

Minitest-rails发电机

[英]Minitest-rails generators

我正在使用minitest-rails(https://github.com/blowmage/minitest-rails),并且效果很好。 但是,一个问题是发电机不工作。 或更确切地说,它似乎总是调用“ test_unit”代替!

这就是我的“ test / minitest_helper.rb”的样子: https ://gist.github.com/3496814(注意,我在那里覆盖了测试单元)

在“ config / application.rb”中,我有这个:

# require "rails/test_unit/railtie" ## Test Unit is not required!

还有这个:

## application.rb
config.generators do |g|
  g.test_framework :mini_test, :spec => true, :fixture => false
end


## Gemfile
group :test, :development do
  gem 'minitest-rails', git: "git://github.com/blowmage/minitest-rails.git"
  gem 'minitest-rails-capybara'
  gem 'factory_girl_rails'
  gem 'turn'
end

不过,例如,当生成模型时,我得到以下信息:( --spec实际上并不重要。无论如何,它都会生成相同的东西)

rails g model Horse --spec
  invoke  active_record
  create    db/migrate/20120828095404_create_horses.rb
  create    app/models/horse.rb
  invoke    test_unit                   ### Invoking test_unit??!
  create      test/unit/horse_test.rb
  invoke      factory_girl
  create        test/factories/horses.rb

如果我只是手动创建文件,那么minitest就像是一种魅力。

为了使发电机正常工作,我还有什么需要做的吗?

目前正在使用Rails 3.2.7。

维护人员已解决了factory_girl_rails gem强制将生成器配置更改为Test::Unit问题,但该问题尚未过滤到rubygems.org

如果您将Gemfile更新为包含:

group :development, :test do
  gem 'factory_girl_rails', :git => "git://github.com/thoughtbot/factory_girl_rails.git"
end

一切都应该很好!

PS:您也可以在执行此操作时从application.rb删除:fixture => false ,因为factory_girl_rails为您设置了此功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM