diff --git a/.travis.yml b/.travis.yml index ca8613f..cd0295c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,10 @@ language: ruby -sudo: false + rvm: +- 2.7 +- 2.6 - 2.5 -- 2.4 -- 2.3 -- 2.2 -- 2.1 -- jruby-9.1.7.0 + env: global: - PARSE_HOST=https://parse-ruby-client-server.herokuapp.com diff --git a/lib/faraday/better_retry.rb b/lib/faraday/better_retry.rb index da92d01..da450fe 100644 --- a/lib/faraday/better_retry.rb +++ b/lib/faraday/better_retry.rb @@ -12,11 +12,11 @@ def initialize(app, options = nil) super(app, options) # NOTE: Faraday 0.9.1 by default does not retry on POST requests - @options.methods << :post + @options.methods = @options.methods + [:post] # NOTE: the default exceptions are lost when custom ones are given default_exceptions = [ - Errno::ETIMEDOUT, 'Timeout::Error', Error::TimeoutError] + Errno::ETIMEDOUT, 'Timeout::Error', TimeoutError] @options.exceptions.concat(default_exceptions) end @@ -33,8 +33,10 @@ def call(env) log(env, exception) retries -= 1 retries_header(env, retries) - sleep sleep_amount(retries + 1) - retry + if (sleep_amount = calculate_sleep_amount(retries + 1, env)) + sleep sleep_amount + retry + end end raise end diff --git a/lib/parse/client.rb b/lib/parse/client.rb index 3399810..faad40e 100644 --- a/lib/parse/client.rb +++ b/lib/parse/client.rb @@ -10,9 +10,9 @@ module Parse # The client that communicates with the Parse server via REST class Client RETRIED_EXCEPTIONS = [ - 'Faraday::Error::TimeoutError', - 'Faraday::Error::ParsingError', - 'Faraday::Error::ConnectionFailed', + 'Faraday::TimeoutError', + 'Faraday::ParsingError', + 'Faraday::ConnectionFailed', 'Parse::ParseProtocolRetry' ] @@ -104,7 +104,7 @@ def request(uri, method = :get, body = nil, query = nil, content_type = nil) # NOTE: Don't leak our internal libraries to our clients. # Extend this list of exceptions as needed. - rescue Faraday::Error::ClientError => e + rescue Faraday::ClientError, Faraday::ConnectionFailed => e raise Parse::ConnectionError, e.message end diff --git a/test/helper.rb b/test/helper.rb index a72b35a..93c5e75 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -26,7 +26,7 @@ # mocha + minitest require 'minitest/unit' -require 'mocha/mini_test' +require 'mocha/minitest' require 'vcr' @@ -40,10 +40,6 @@ $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'parse-ruby-client' -if RUBY_VERSION[0..2] < '2.2' - YAML::ENGINE.yamler = 'syck' # get ascii strings as strings in fixtures -end - VCR.configure do |c| c.cassette_library_dir = 'test/fixtures/vcr_cassettes' c.default_cassette_options = { record: :once } diff --git a/test/middleware/better_retry_test.rb b/test/middleware/better_retry_test.rb index bcd3fc5..a136129 100644 --- a/test/middleware/better_retry_test.rb +++ b/test/middleware/better_retry_test.rb @@ -14,8 +14,8 @@ def conn(retry_options = {}) default_options = { logger: @logger, exceptions: [ - 'Faraday::Error::TimeoutError', - 'Faraday::Error::ParsingError', + 'Faraday::TimeoutError', + 'Faraday::ParsingError', 'Parse::ParseProtocolRetry' ] } diff --git a/test/middleware/extend_parse_json_test.rb b/test/middleware/extend_parse_json_test.rb index 48eb4a2..fadc437 100644 --- a/test/middleware/extend_parse_json_test.rb +++ b/test/middleware/extend_parse_json_test.rb @@ -18,7 +18,7 @@ def conn(_retry_options = {}) end def test_invalid_json - assert_raises(Faraday::Error::ParsingError) { conn.get('/invalid_json') } + assert_raises(Faraday::ParsingError) { conn.get('/invalid_json') } end def test_valid_json diff --git a/test/test_client_create.rb b/test/test_client_create.rb index 5810d15..26f0e0b 100644 --- a/test/test_client_create.rb +++ b/test/test_client_create.rb @@ -61,7 +61,7 @@ def test_wraps_connection_errors VCR.use_cassette('test_client_wraps_connection_errors') do _stubs, client = stubbed_client do |stub| stub.get(stub_path) do - raise Faraday::Error::ConnectionFailed, 'message' + raise Faraday::ConnectionFailed, 'message' end end