diff options
| author | mo <mo@mokhan.ca> | 2018-11-10 19:39:33 -0700 |
|---|---|---|
| committer | mo <mo@mokhan.ca> | 2018-11-10 19:39:33 -0700 |
| commit | dc612620ab4b9704519e37aa168c5c2d9c083bd1 (patch) | |
| tree | 483e2de36e85dd7c0a8efc2001717e4d88f14872 /test | |
| parent | 2edc66973dcf57122f6e6e2956e4f9ee66167152 (diff) | |
fix off by one on retry logic.
Diffstat (limited to 'test')
| -rw-r--r-- | test/net/client_test.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/test/net/client_test.rb b/test/net/client_test.rb index d44a336..9ffd67f 100644 --- a/test/net/client_test.rb +++ b/test/net/client_test.rb @@ -23,13 +23,27 @@ class ClientTest < Minitest::Test WebMock.stub_request(:get, uri.to_s) .to_timeout.then .to_timeout.then + .to_timeout.then .to_return(status: 200, body: { 'success' => 'true' }.to_json) response = subject.with_retry(retries: 3) do |client| client.get(uri) end refute_nil response - assert_equal response.class, Net::HTTPOK - assert_equal('true', JSON.parse(response.body)['success']) + assert_equal Net::HTTPOK, response.class + assert_equal JSON.parse(response.body)['success'], 'true' + end + + def test_exceeds_retries + uri = URI.parse('https://www.example.org/api/scim/v2/schemas') + WebMock.stub_request(:get, uri.to_s) + .to_timeout.then + .to_return(status: 200, body: { 'success' => 'true' }.to_json) + + assert_raises Net::OpenTimeout do + subject.with_retry(retries: 0) do |client| + client.get(uri) + end + end end def test_get_with_string_uri |
