在创建新的 Rails 应用程序时,如何告诉 Rails 使用 RSpec 而不是 test-unit? [英] How can I tell Rails to use RSpec instead of test-unit when creating a new Rails app?

查看:37
本文介绍了在创建新的 Rails 应用程序时,如何告诉 Rails 使用 RSpec 而不是 test-unit?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了 test-unitrspec(连同 -core-expectations-mocks-rails 版本 2.6.x).当我运行命令 rails new foo 时,它使用 test-unit 来生成测试存根文件而不是 rspec.

I have test-unit installed and rspec installed (along with -core, -expectations, -mocks and -rails version 2.6.x). When I run the command rails new foo, it uses test-unit to generate the test stub files instead of rspec.

是否可以告诉 rails 使用 rspec 来生成测试?

Is there an option where I can tell rails to use rspec to generate the tests instead?

推荐答案

以下应该有效:

rails new MYAPP -T # The -T option tells rails not to include Test::Unit

在 Gemfile 中:

gem 'rspec-rails'

在命令行:

bundle install
rails g rspec:install

这篇关于在创建新的 Rails 应用程序时,如何告诉 Rails 使用 RSpec 而不是 test-unit?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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