How to run multiple spec files in RSpec using single command in terminal?

生来就可爱ヽ(ⅴ<●) 提交于 2020-06-17 01:38:29

问题


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


回答1:


Yes, you can.

For multiple files without a pattern

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

If you want to exclude some files

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

see this for more info https://relishapp.com/rspec/rspec-core/v/3-8/docs/command-line/pattern-option

Multiple files starting with some char or phrase

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

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

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

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


For running the failing tests only

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



来源:https://stackoverflow.com/questions/51562680/how-to-run-multiple-spec-files-in-rspec-using-single-command-in-terminal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!