How do I run an rspec test only when a flag is set?
I am using Stripe-Ruby-Mock and they use a live
flag. However, I do not want the test to run when -t live
is not set.
bundle exec rspec -t live spec
it "should run rspec test, only when live is true", live: true do
expect('value').to eq('value')
end
Currently, my test runs when -t live
is set AND when it's not.
Configure RSpec to filter out that tag by default in your spec_helper.rb
using #filter_run_excluding
:
config.filter_run_excluding live: true
That way they will only run when you specify the tag on the command line.