Rails + Rspec Testing strategies


(Chris O'donnell) #1

Has anyone come up with a successful testing strategy. Rails 5 + RSpec. With moving money around, I really want a well tested app. Though I fear that the only way to do this is to hit the sandbox api each time.

however I’m running into the following issues:

  1. Pulling down a real auth token for every test would be a painfully slow. So I looked at vcr and web mock. However the tokens are only good for 1hour and the recommended refresh rate is every minute. This does sit well. Even a fast test suite on a large application could take well over a full minute to run.

  2. So seems the only way to do this is to hit the sandbox app for each request. However, this could introduce all types of issues. As I use Faker gem to generate random data. Ultimately the random data would start to overlap, causing issues.

Solutions:

  1. Configure the sandbox app to be open no auth token. Pure Logic testing allowing for mockable endpoints, so that they would not stop working when the auth token times out.

OR
2) database clean the sandbox application at the end of each full suite run.

any thoughts on this?