Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore or skip a test method using RSpec?

please guide how to disable one of the below test methods using RSpec. I am using Selenuim WebDriver + RSpec combinations to run tests.

require 'rspec' require 'selenium-webdriver'  describe 'Automation System' do    before(:each) do         ###   end    after(:each) do     @driver.quit   end    it 'Test01' do       #positive test case   end    it 'Test02' do       #negative test case   end     end 
like image 717
Prashanth Sams Avatar asked Dec 04 '14 07:12

Prashanth Sams


People also ask

How do I skip a test in RSpec?

- In RSpec, it's also possible to skip over certain examples. We can do that by marking them as being pending, or by telling it that it ought to skip them.

What is pending in RSpec?

`pending` examples 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. `pending` for an example that is currently passing.

Does RSpec clean database?

I use the database_cleaner gem to scrub my test database before each test runs, ensuring a clean slate and stable baseline every time. By default, RSpec will actually do this for you, running every test with a database transaction and then rolling back that transaction after it finishes.


1 Answers

You can use pending() or change it to xit or wrap assert in pending block for wait implementation:

describe 'Automation System' do    # some code here    it 'Test01' do      pending("is implemented but waiting")   end    it 'Test02' do      # or without message      pending   end    pending do     "string".reverse.should == "gnirts"   end    xit 'Test03' do      true.should be(true)   end     end 
like image 103
Philidor Avatar answered Oct 16 '22 09:10

Philidor