Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I exclude RSpec tests matching a specific tag?

Tags:

ruby

rspec

When running my RSpec tests from the command line, how can I exclude tests matching a specific tag?

like image 475
Nathan Long Avatar asked Nov 14 '11 16:11

Nathan Long


People also ask

How do I run a specific test in RSpec?

Running tests by their file or directory names is the most familiar way to run tests with RSpec. RSpec can take a file name or directory name and run the file or the contents of the directory. So you can do: rspec spec/jobs to run the tests found in the jobs directory.

What does RSpec describe do?

RSpec is a testing tool for Ruby, created for behavior-driven development (BDD). It is the most frequently used testing library for Ruby in production applications. Even though it has a very rich and powerful DSL (domain-specific language), at its core it is a simple tool which you can start using rather quickly.

How do I cancel RSpec?

One can stop the RSpec test in the middle by pressing ctrl-C twice.


1 Answers

Use ~@ with the name of the tag, like this:

rspec spec --tag ~@slow

See the docs: https://www.relishapp.com/rspec/rspec-core/docs/command-line/tag-option

Update

I'm now running my tests on Spork, and it seems as though it ignores this directive. Not sure why.

like image 126
Nathan Long Avatar answered Sep 22 '22 07:09

Nathan Long