如何在“rails new app --skip-test-unit"之后重新启用 Rails 4 中的 Test::Unit [英] How to re-enable Test::Unit in Rails 4 after 'rails new app --skip-test-unit'

查看:25
本文介绍了如何在“rails new app --skip-test-unit"之后重新启用 Rails 4 中的 Test::Unit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用过

rails new app --skip-test-unit

因为最初,我想我可以稍后添加测试.

because initially, I thought I could add testing later.

我开发了应用的很大一部分.

I developed a significant portion of my app.

现在,我想添加 Test::Unit,但找不到任何有关如何操作的文档.谷歌搜索只会让我找到 Rails 指南和教程,这些指南和教程假设您在第一次创建应用程序时没有要求 Rails 跳过测试框架.

Now, I would like to add Test::Unit but I couldn't find any documentation on how to do it. Googling only lead me to the Rails Guides and tutorials that assume you didn't ask rails to skip the testing framework when you first created the app.

我知道我可能能够弄清楚要手动添加哪些 _test.rb 文件以及如何修改 Rakefile(通过查看在不跳过测试的情况下创建的应用程序),但我更喜欢找到一种更简单的方法(如果存在).

I know I might be able to figure out what _test.rb files to add manually and how to modify the Rakefile (by looking at an app that was created without skipping tests) but I prefer to find an easier approach if it exists.

我认为 --skip-test-unit 在某处写了一些东西来告诉 Rails 生成器不要生成测试,并且它删除了与测试相关的 rake 任务.

I think the --skip-test-unit writes something somewhere to tell the Rails generators not to generate tests, and as well, it removes the rake tasks related to tests.

最好找出是否有命令(或修改配置文件)将 Test::Unit 恢复到我的 Rails 应用程序.

It would be good to find out if there is a command (or a config file modification) to restore Test::Unit to my Rails app.

我不一定介意现有的控制器/模型是否没有测试,我也不一定想向它们添加测试,但展望未来,我希望由生成器生成测试,我会喜欢能跑

I don't necessarily mind if the existing controllers/models do not have tests and I don't necessarily want to add tests to them, but going forward, I would like tests to be generated by the generators, and I would like to be able to run

rake test

推荐答案

config/application.rb:

config/application.rb:

取消注释以下行:

require "rails/test_unit/railtie"

这篇关于如何在“rails new app --skip-test-unit"之后重新启用 Rails 4 中的 Test::Unit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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