Skip to content

Commit

Permalink
Better: Compatibility with faraday 2 (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
ylecuyer authored Sep 27, 2022
1 parent d1c56ec commit 7191d44
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ group :development, :test do
gem "psych", '< 4.0.0' # safe_load signature not compatible with older rubies
gem "rake"
gem "typhoeus" unless defined? JRUBY_VERSION
gem 'faraday-typhoeus' unless defined? JRUBY_VERSION
end

group :test do
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ New features:

Updated features:

* Removed restriction on faraday < 2 ([#666](https://github.com/arsduo/koala/pull/666))

Removed features:

Internal improvements:
Expand Down
3 changes: 2 additions & 1 deletion koala.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Gem::Specification.new do |gem|

gem.required_ruby_version = '>= 2.1'

gem.add_runtime_dependency("faraday", "< 2")
gem.add_runtime_dependency("faraday")
gem.add_runtime_dependency("faraday-multipart")
gem.add_runtime_dependency("addressable")
gem.add_runtime_dependency("json", ">= 1.8")
gem.add_runtime_dependency("rexml")
Expand Down
1 change: 1 addition & 0 deletions lib/koala/http_service.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'faraday'
require 'faraday/multipart' unless defined? Faraday::FilePart # hack for faraday < 1.9 to avoid warnings
require 'koala/http_service/uploadable_io'
require 'koala/http_service/response'
require 'koala/http_service/request'
Expand Down
1 change: 0 additions & 1 deletion lib/koala/http_service/uploadable_io.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require "net/http/post/multipart"
require "tempfile"

module Koala
Expand Down
4 changes: 2 additions & 2 deletions spec/cases/http_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def adapter(arg)

expect_any_instance_of(Faraday::Connection).to receive(:get) do |instance|
expect(instance.builder.handlers).to eq([
Faraday::Request::Multipart,
Faraday::Multipart::Middleware,
Faraday::Request::UrlEncoded,
])
mock_http_response
Expand All @@ -219,7 +219,7 @@ def adapter(arg)

expect_any_instance_of(Faraday::Connection).to receive(:get) do |instance|
expect(instance.builder.handlers).to eq([
Faraday::Request::Multipart,
Faraday::Multipart::Middleware,
Faraday::Request::UrlEncoded,
])
mock_http_response
Expand Down
6 changes: 3 additions & 3 deletions spec/support/koala_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ def self.activate_adapter!
# JRuby doesn't support typhoeus on Travis
unless defined? JRUBY_VERSION
require adapter
require 'typhoeus/adapters/faraday' if adapter.to_s == "typhoeus"
require "faraday/#{adapter}"
Faraday.default_adapter = adapter.to_sym
end
rescue ParserError
puts "Unable to load adapter #{adapter}, using Net::HTTP."
rescue => e
puts "Unable to load adapter #{adapter}, using Net::HTTP. #{e.class} #{e.message}"
ensure
@adapter_activation_attempted = true
end
Expand Down

0 comments on commit 7191d44

Please sign in to comment.