RubyMoney / google_currency

Ruby Money::Bank interface for the Google Currency exchange data
http://rubymoney.github.com/google_currency
MIT License
182 stars 90 forks source link

Better rate fetch failure handling #27

Closed sporkmonger closed 10 years ago

sporkmonger commented 10 years ago

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.

semmons99 commented 10 years ago

let's remove comments and test this

sporkmonger commented 10 years ago

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.

sporkmonger commented 10 years ago

Actually, nevermind, I can stub the read method to be stateful.

semmons99 commented 10 years ago

exactly, stubs and mocks are your friends here. You could probably even doctor up a VCR based solution.