在Rails中禁用单元测试生成器

时间:2011-12-13 23:22:55

标签: ruby-on-rails unit-testing rspec generator

有谁知道如何禁用Rails中的自动单元测试文件生成?无论何时创建控制器,模型或迁移,它都会在test /目录中创建关联文件;我需要禁用此功能。

此外,是否可以使RPsec接管,以便在执行标准rails g model | controller | migration命令时使用RSpec(在spec /目录中)创建文件?

1 个答案:

答案 0 :(得分:29)

你在application.rb

中想要这样的东西
config.generators do |g|
    g.test_framework  :rspec, :fixture => false
    g.view_specs      false
    g.helper_specs    false
end

更多信息:http://guides.rubyonrails.org/generators.html#customizing-your-workflow

就个人而言,我使用这个:

config.generators do |g|
    g.orm             :mongoid
    g.template_engine :haml
    g.test_framework  :rspec, :fixture => false
    g.view_specs      false
    g.helper_specs    false
    g.fixture_replacement :fabrication
end