Leo Le Leo Le - 2 years ago 102
Ruby Question

Run group of test in rspec

My application has some functions that are using httparty service to get data from another website. So it takes a lot of time when run the test for http functions.

- spec
-- services
--- http_request
---- test_http_a_spec.rb
---- test_http_b_spec.rb
--- component
---- test_component_c_spec.rb
---- test_component_d_spec.rb
--- models
---- test_model_e_spec.rb

So how can I run rspec test for all tests except the tests in
folder ?

Answer Source

You may want to tag your http tests with rspec filters and rspec tags.

For example, in spec/services/http_request/test_http_a_spec.rb:

describe WhatEver
  describe 'Testing', http: true do
     it 'should work' do
       # ...

And then, run your tests with rspec --tag ~http. Tests with tag http: true will not be executed.

On the other hand, if your http tests are taking so long to execute, you may probably want to read this article.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download