如何在 RSpec 中运行单个测试/规范文件? [英] How do you run a single test/spec file in RSpec?

查看:42
本文介绍了如何在 RSpec 中运行单个测试/规范文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够运行单个规范文件的测试 —例如,对于我正在编辑的一个文件.rake spec 执行所有规范.我的项目不是 Rails 项目,所以 rake spec:doc 不起作用.

不知道这是否重要,但这是我的目录结构.

<前>./Rakefile./lib./lib/垫子.rb./lib/垫子./lib/垫子/doc.rb./lib/垫子/db.rb./规格./spec/spec.opts./spec/spec_helper.rb./spec/db_spec.rb

解决方案

或者你可以跳过 rake 并使用 'rspec' 命令:

rspec path/to/spec/file.rb

在您的情况下,我认为只要您的 ./spec/db_spec.rb 文件包含适当的帮助程序,它就应该可以正常工作.

如果您使用的是旧版本的 rspec,则为:

spec path/to/spec/file.rb

I want to be able to run a single spec file's tests — for the one file I'm editing, for example. rake spec executes all the specs. My project is not a Rails project, so rake spec:doc doesn't work.

Don't know if this matters, but here is my directory structure.

./Rakefile
./lib
./lib/cushion.rb
./lib/cushion
./lib/cushion/doc.rb
./lib/cushion/db.rb
./spec
./spec/spec.opts
./spec/spec_helper.rb
./spec/db_spec.rb

解决方案

Or you can skip rake and use the 'rspec' command:

rspec path/to/spec/file.rb

In your case I think as long as your ./spec/db_spec.rb file includes the appropriate helpers, it should work fine.

If you're using an older version of rspec it is:

spec path/to/spec/file.rb

这篇关于如何在 RSpec 中运行单个测试/规范文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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