在Rails中禁用单元测试生成器 [英] Disable unit testing generators in Rails

查看:107
本文介绍了在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.

还可以在执行标准rails g model | controller | migration命令时使RPsec接管,以便使用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-工作流程

我个人使用这个:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆