Search code examples
rubyrspec

How to tell rspec to run without pending tests output?


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

Solution

  • 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