My app uses Braintree to process payments. Unfortunately the fake_braintree gem is depreciated with the current braintree API, so I am forced to hit the braintree sandbox servers with my tests, which is extremely slow (if anyone can help with that issue or recommend an alternative, that'd be awesome too).
My question is, could I group or tag all my tests that hit Braintree servers, and not run them by default, and specify an argument to run all tests including those? So ideally I'd want the 'rspec' command to skip those tests, and then running 'rspec --include-braintree' to run all my tests, including the ones that hit the braintree servers.
I feel like this would be a good happy medium so I don't sit around waiting on external API calls every time I run my test suite.
Yes, you can use:
# spec/spec_helper.rb
RSpec.configure do |config|
config.filter_run_excluding braintree: true unless ENV['BRAINTREE']
end
Mark a test with the tag (or an entire block if you want):
it "does stuff", braintree: true do
end
And you can easily do: BRAINTREE=1 rspec
to run tests including braintree tests