Ruby on Rails:从test_unit切换到rspec [英] Ruby on Rails: Switch from test_unit to rspec

查看:97
本文介绍了Ruby on Rails:从test_unit切换到rspec的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览一个建议使用 rspec 的教程,但我已经经历了很多默认的rails安装。我真的不想重做安装。无论如何,当我运行

  $ rails g integration_test命名为

我得到

  invoke test_unit 
create test / integration / named_test.rb

当我运行 bundle 时,列出了各种 rspec gems,但是 test_unit 不是。本教程似乎有轨道调用 rspec 而不是 test_unit ,而无需额外执行任何操作。如何让rails使用集成测试生成器命令来使用 rspec

解决方案

config / application.rb 文件中:

  config .generators do | g | 
g.test_framework:rspec
end

现在,当您运行生成器时,你得到rspec测试文件。记得重新启动你的服务器。有关发电机组的更多信息,请参阅:如果你真的想使用integration_test生成器:

  rails g integration_test named --integration-tool = rspec 


I'm going through a tutorial that has suggested using rspec, but I have already gone through a lot of default rails installation. I really don't want to have to redo the installation at all. Anyway, when I run

$ rails g integration_test named

I get

  invoke  test_unit
  create    test/integration/named_test.rb

When I run bundle, various rspec gems are listed, but test_unit is not. The tutorial seems to have rails invoke rspec instead of test_unit without doing anything additional. How do I get rails to use rspec with the integration test generator command?

解决方案

In your config/application.rb file :

config.generators do |g|
  g.test_framework :rspec
end

Now when you run your generators, you get rspec test files. Remember to restart your server. For more information on generators see:

RailsCasts #216 Generators in Rails 3

If you really want to use the integration_test generator:

rails g integration_test named --integration-tool=rspec

这篇关于Ruby on Rails:从test_unit切换到rspec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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