Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell rspec to run without pending tests output?

Tags:

ruby

rspec

Is there a way (maybe some key) to tell rspec to skip pending tests and don't print information about them?

I have some auto generated tests like

pending "add some examples to (or delete) #{__FILE__}"

I run "bundle exec rspec spec/models --format documentation" and get somethin like this:

Rating
  allows to rate first time
  disallow to rate book twice

Customer
  add some examples to (or delete) /home/richelieu/Code/first_model/spec/models/customer_spec.rb (PENDING: No reason given)

Category
  add some examples to (or delete) /home/richelieu/Code/first_model/spec/models/category_spec.rb (PENDING: No reason given)
......

I want to keep this files, cause I gonna change them later, but for now I want output like:

Rating
  allows to rate first time
  disallow to rate book twice

Finished in 0.14011 seconds
10 examples, 0 failures, 8 pending
like image 233
GriwMF Avatar asked Jan 03 '14 18:01

GriwMF


People also ask

What is pending in RSpec?

RSpec offers a number of different ways to indicate that an example is. disabled pending some action. `pending` any arbitrary reason with a failing example. `pending` any arbitrary reason with a passing example.

How do I run an RSpec on a specific file?

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?

The word describe is an RSpec keyword. It is used to define an “Example Group”. You can think of an “Example Group” as a collection of tests. The describe keyword can take a class name and/or string argument.


1 Answers

Take a look at tags -

You could do something like this in your test file

describe "the test I'm skipping for now" do     
  it "slow example", :skip => true do
    #test here
  end
end

and run your tests like this:

bundle exec rspec spec/models --format documentation --tag ~skip

where the ~ character excludes all tests with the following tag, in this case skip

like image 191
dax Avatar answered Sep 21 '22 03:09

dax