From 6ce8a9d5f78bfb671e980f942af9cd89288b307e Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 14 May 2020 17:51:15 -0400 Subject: [PATCH] Test against Faraday 0.9, 0.17 and 1.0+. --- .travis.yml | 15 +++++++-------- CHANGELOG.md | 1 + Gemfile | 2 ++ test/test_helper.rb | 7 ++++++- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 18b789e..08402d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,21 +5,20 @@ sudo: false matrix: include: - rvm: 2.6.6 - - rvm: 2.5.5 - - rvm: 2.4.6 - - rvm: 2.4.6 + env: FARADAY_VERSION=0.9.0 + - rvm: 2.6.6 + env: FARADAY_VERSION=0.17.0 + - rvm: 2.6.6 + env: FARADAY_VERSION="~> 1.0" + - rvm: 2.6.6 script: - bundle exec danger + - rvm: 2.3.8 - rvm: jruby-9.2.7.0 - rvm: jruby-head - - rvm: 2.3.8 - rvm: ruby-head allow_failures: - rvm: ruby-head - rvm: jruby-head -before_install: - - gem update --system - - gem install bundler - bundler_args: --without development diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e55eab..e11ceb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### 0.9.4 (Next) +* [#163](https://github.com/codegram/hyperclient/pull/163): Test against Faraday 0.9, 0.17 and 1.0+ - [@dblock](https://github.com/dblock). * Your contribution here. ### 0.9.3 (2020/05/14) diff --git a/Gemfile b/Gemfile index 31b7b16..23992ca 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,8 @@ git_source(:github) { |repo| "https://github.com/#{repo['/'] ? repo : "#{repo}/# source 'https://rubygems.org' +gem 'faraday', ENV['FARADAY_VERSION'] if ENV.key?('FARADAY_VERSION') + gemspec group :development do diff --git a/test/test_helper.rb b/test/test_helper.rb index 7d490be..80bd6f7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,6 +7,11 @@ MiniTest::Test.class_eval do def stub_request(conn, adapter_class = Faraday::Adapter::Test, &stubs_block) - conn.builder.adapter adapter_class, &stubs_block + adapter_handler = conn.builder.handlers.find { |h| h.klass < Faraday::Adapter } + if adapter_handler + conn.builder.swap(adapter_handler, adapter_class, &stubs_block) + else + conn.builder.adapter adapter_class, &stubs_block + end end end