测试文件夹不存在,使用 Rspec [英] Test folder does not exist, using Rspec

查看:68
本文介绍了测试文件夹不存在,使用 Rspec的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用

rails new app -T

这个命令不应该默认创建一个测试文件夹吗?

我正在尝试在我的 ruby​​ 项目中添加 test 文件夹.这是我的 gem 文件:

I am trying to add the test folder in my ruby project. here is my gem file:

group :development, :test do

  gem 'rspec', '~> 3.4'
  gem 'byebug'

  gem 'sqlite3'
end

然后:

bundle install --without production

即使刷新项目后,它也不会在我的项目中生成测试文件夹?

it does not generate the test folder inside my project even after refreshing the project?

推荐答案

由于您使用的是 RoR,如果您认为需要安装 rspec-rails 而不是 rspec.要创建 test 目录(实际上是 spec),您需要运行 rspec 安装程序:rails 生成 rspec:install

Since you are using RoR, if think you need to install rspec-rails instead of rspec. To create the test directory (spec, actually) you need to run the rspec installer: rails generate rspec:install

使用 -T 选项,您将跳过 unit-test 框架,因为您想使用 rspec,对吗?如果是这种情况您不需要测试目录.rspec 改为使用 spec 目录.正如我所说,要创建 spec 文件夹,您需要像这样运行 rspec 安装程序:

With -T option your are skipping the unit-test framework because you want to use rspec, am I right? If this is the case you don't need a test directory. rspec uses the spec directory instead. As I said, to create the spec folder you need to run the rspec installer like this:

rails generate rspec:install

这篇关于测试文件夹不存在,使用 Rspec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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