Leo Le
Leo Le

Reputation: 825

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 http_request folder ? Thanks

Upvotes: 1

Views: 2356

Answers (1)

Wikiti
Wikiti

Reputation: 1636

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
       # ...
     end
  end
end

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.

Upvotes: 5

Related Questions