This has a lot of cool use cases, but I'm using it for running rspec tests in parallel on my CI service. For example:
  describe 'get averages but takes a long time', slow: true do
    it 'gets average foo' do
      ....
    end
    it 'gets average bar' do
      ...
    end
  end
Then, to run only tests tagged as "slow", run rspec with this command:
  rspec --tag slowAnother option is to have rspec automatically NOT run certain examples, such as "slow":
  RSpec.configure do |c|
    c.filter_run_excluding slow: true 
  end
Then, to run all examples:
  
  RSpec.configure do |c|
    c.filter_run_excluding slow: true unless ENV[‘ALL’]
  end
Then run rspec with this command:
  ALL=1 rspecI can also run all tagged tests without doing any rspec configuration using this command:
  rspec . --tag type:special
Or I can run all tests EXCEPT certain tagged tests using this command:
  rspec . --tag ~type:special
Thanks to Myron Marston on StackOverflow for this nifty trick.
 
No comments:
Post a Comment