在 Rails 中禁用单元测试生成器 [英] Disable unit testing generators in Rails
问题描述
有谁知道如何在 Rails 中禁用自动单元测试文件生成?每当创建控制器、模型或迁移时,它都会在 test/目录中创建相关文件;我需要禁用此功能.
Does anyone know how to disable the automatic unit test file generation in Rails? Whenever a controller, model or migration is created then it creates the associated files in the test/ directory; I need this disabled.
此外,是否可以让 RPsec 接管,以便在执行标准 rails g model|controller|migration 命令时使用 RSpec(在 spec/目录中)创建文件?
Also, is it possible to make RPsec take over so that the files are created with RSpec (in the spec/ directory) when a standard rails g model|controller|migration command is performed?
推荐答案
你想要在你的应用程序中这样的东西.rb
You want something like this in your 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-工作流程
就个人而言,我使用这个:
Personally, I use this one:
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
这篇关于在 Rails 中禁用单元测试生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!