如何在终端中使用单个命令在 RSpec 中运行多个规范文件? [英] How to run multiple spec files in RSpec using single command in terminal?

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

问题描述

我需要一次性运行 RSpec 来处理我选择的多个文件,谁能指导我完成它?我是初学者所以请解释清楚

I need to run RSpec at one go for multiple files of my choice can anyone guide me through it? I am a beginner so please explain clearly

推荐答案

是的,你可以.

您可以使用以下语法为多个文件运行规范:

You can use the following syntax to run your specs for multiple files:

rspec path/to/first/file path/to/second/file


具有模式的多个文件

如果您希望从某些特定文件夹运行规范,那么您可以使用


Multiple files with pattern

If you wish to run spec from some specific folders then you might use

rspec --pattern=./spec/features/**/*_spec.rb

如果你想排除一些文件

rspec --pattern=./spec/features/**/*_spec.rb --exclude-pattern="./spec/features/{folder1,folder2}/**/*_spec.rb"

查看更多信息https://relishapp.com/rspec/rspec-core/v/3-8/docs/command-line/pattern-option

rspec --pattern="./spec/features/[t]*_spec.rb"

在这里,它将运行文件名以 t 开头的所有规范.

Here, it will run all specs with filename starting with t.

rspec --pattern="./spec/features/[tran|u]*_spec.rb"

在这里,它将运行文件名以 tranu 开头的所有规范.

Here, it will run all specs with filename starting with tran or u.

您可以使用 rspec --only-failures 选项,该选项只会加载和运行失败的规范文件.

You can use the rspec --only-failures option which will only load and run spec files with failures.

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

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