Closed sporkmonger closed 10 years ago
let's remove comments and test this
You know... to be honest I have no idea how to test the 'fails on the first try but succeeds on the subsequent try' scenario with the test setup you've got...
I can at least test the 'pulls from the cache instead on error' scenario though.
Actually, nevermind, I can stub the read method to be stateful.
exactly, stubs and mocks are your friends here. You could probably even doctor up a VCR based solution.
If the rate fetch fails, retry 3 times. If it still fails after 3 retries, and we previously had a cached value for that rate, keep using the cached value. If all 3 retries fail and we have no previously cached rate, raise the HTTP error.