faraday 0.17.6 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -8
- data/LICENSE.md +1 -1
- data/README.md +18 -358
- data/Rakefile +1 -7
- data/examples/client_spec.rb +65 -0
- data/examples/client_test.rb +79 -0
- data/lib/faraday/adapter/em_http.rb +142 -99
- data/lib/faraday/adapter/em_http_ssl_patch.rb +24 -18
- data/lib/faraday/adapter/em_synchrony/parallel_manager.rb +18 -15
- data/lib/faraday/adapter/em_synchrony.rb +104 -60
- data/lib/faraday/adapter/excon.rb +98 -56
- data/lib/faraday/adapter/httpclient.rb +83 -59
- data/lib/faraday/adapter/net_http.rb +129 -63
- data/lib/faraday/adapter/net_http_persistent.rb +50 -27
- data/lib/faraday/adapter/patron.rb +80 -43
- data/lib/faraday/adapter/rack.rb +30 -13
- data/lib/faraday/adapter/test.rb +86 -53
- data/lib/faraday/adapter/typhoeus.rb +4 -1
- data/lib/faraday/adapter.rb +82 -22
- data/lib/faraday/adapter_registry.rb +30 -0
- data/lib/faraday/autoload.rb +47 -36
- data/lib/faraday/connection.rb +312 -182
- data/lib/faraday/dependency_loader.rb +37 -0
- data/lib/faraday/encoders/flat_params_encoder.rb +98 -0
- data/lib/faraday/encoders/nested_params_encoder.rb +171 -0
- data/lib/faraday/error.rb +9 -35
- data/lib/faraday/file_part.rb +128 -0
- data/lib/faraday/logging/formatter.rb +105 -0
- data/lib/faraday/middleware.rb +12 -28
- data/lib/faraday/middleware_registry.rb +129 -0
- data/lib/faraday/options/connection_options.rb +22 -0
- data/lib/faraday/options/env.rb +181 -0
- data/lib/faraday/options/proxy_options.rb +28 -0
- data/lib/faraday/options/request_options.rb +22 -0
- data/lib/faraday/options/ssl_options.rb +59 -0
- data/lib/faraday/options.rb +32 -183
- data/lib/faraday/param_part.rb +53 -0
- data/lib/faraday/parameters.rb +4 -197
- data/lib/faraday/rack_builder.rb +66 -55
- data/lib/faraday/request/authorization.rb +44 -30
- data/lib/faraday/request/basic_authentication.rb +14 -7
- data/lib/faraday/request/instrumentation.rb +45 -27
- data/lib/faraday/request/multipart.rb +79 -48
- data/lib/faraday/request/retry.rb +197 -171
- data/lib/faraday/request/token_authentication.rb +15 -10
- data/lib/faraday/request/url_encoded.rb +43 -23
- data/lib/faraday/request.rb +68 -38
- data/lib/faraday/response/logger.rb +22 -69
- data/lib/faraday/response/raise_error.rb +38 -18
- data/lib/faraday/response.rb +24 -14
- data/lib/faraday/utils/headers.rb +139 -0
- data/lib/faraday/utils/params_hash.rb +61 -0
- data/lib/faraday/utils.rb +36 -245
- data/lib/faraday.rb +94 -175
- data/spec/external_adapters/faraday_specs_setup.rb +14 -0
- data/spec/faraday/adapter/em_http_spec.rb +47 -0
- data/spec/faraday/adapter/em_synchrony_spec.rb +16 -0
- data/spec/faraday/adapter/excon_spec.rb +49 -0
- data/spec/faraday/adapter/httpclient_spec.rb +73 -0
- data/spec/faraday/adapter/net_http_persistent_spec.rb +57 -0
- data/spec/faraday/adapter/net_http_spec.rb +64 -0
- data/spec/faraday/adapter/patron_spec.rb +18 -0
- data/spec/faraday/adapter/rack_spec.rb +8 -0
- data/spec/faraday/adapter/typhoeus_spec.rb +7 -0
- data/spec/faraday/adapter_registry_spec.rb +28 -0
- data/spec/faraday/adapter_spec.rb +55 -0
- data/spec/faraday/composite_read_io_spec.rb +80 -0
- data/spec/faraday/connection_spec.rb +691 -0
- data/spec/faraday/error_spec.rb +0 -57
- data/spec/faraday/middleware_spec.rb +26 -0
- data/spec/faraday/options/env_spec.rb +70 -0
- data/spec/faraday/options/options_spec.rb +297 -0
- data/spec/faraday/options/proxy_options_spec.rb +37 -0
- data/spec/faraday/options/request_options_spec.rb +19 -0
- data/spec/faraday/params_encoders/flat_spec.rb +34 -0
- data/spec/faraday/params_encoders/nested_spec.rb +134 -0
- data/spec/faraday/rack_builder_spec.rb +196 -0
- data/spec/faraday/request/authorization_spec.rb +88 -0
- data/spec/faraday/request/instrumentation_spec.rb +76 -0
- data/spec/faraday/request/multipart_spec.rb +274 -0
- data/spec/faraday/request/retry_spec.rb +242 -0
- data/spec/faraday/request/url_encoded_spec.rb +83 -0
- data/spec/faraday/request_spec.rb +109 -0
- data/spec/faraday/response/logger_spec.rb +220 -0
- data/spec/faraday/response/middleware_spec.rb +68 -0
- data/spec/faraday/response/raise_error_spec.rb +15 -15
- data/spec/faraday/response_spec.rb +75 -0
- data/spec/faraday/utils/headers_spec.rb +82 -0
- data/spec/faraday/utils_spec.rb +56 -0
- data/spec/faraday_spec.rb +37 -0
- data/spec/spec_helper.rb +63 -36
- data/spec/support/disabling_stub.rb +14 -0
- data/spec/support/fake_safe_buffer.rb +15 -0
- data/spec/support/helper_methods.rb +133 -0
- data/spec/support/shared_examples/adapter.rb +104 -0
- data/spec/support/shared_examples/params_encoder.rb +18 -0
- data/spec/support/shared_examples/request_method.rb +234 -0
- data/spec/support/streaming_response_checker.rb +35 -0
- data/spec/support/webmock_rack_app.rb +68 -0
- metadata +66 -38
- data/lib/faraday/deprecate.rb +0 -109
- data/lib/faraday/upload_io.rb +0 -77
- data/spec/faraday/deprecate_spec.rb +0 -147
- data/test/adapters/default_test.rb +0 -14
- data/test/adapters/em_http_test.rb +0 -30
- data/test/adapters/em_synchrony_test.rb +0 -32
- data/test/adapters/excon_test.rb +0 -30
- data/test/adapters/httpclient_test.rb +0 -34
- data/test/adapters/integration.rb +0 -263
- data/test/adapters/logger_test.rb +0 -136
- data/test/adapters/net_http_persistent_test.rb +0 -114
- data/test/adapters/net_http_test.rb +0 -79
- data/test/adapters/patron_test.rb +0 -40
- data/test/adapters/rack_test.rb +0 -38
- data/test/adapters/test_middleware_test.rb +0 -157
- data/test/adapters/typhoeus_test.rb +0 -38
- data/test/authentication_middleware_test.rb +0 -65
- data/test/composite_read_io_test.rb +0 -109
- data/test/connection_test.rb +0 -738
- data/test/env_test.rb +0 -268
- data/test/helper.rb +0 -75
- data/test/live_server.rb +0 -67
- data/test/middleware/instrumentation_test.rb +0 -88
- data/test/middleware/retry_test.rb +0 -282
- data/test/middleware_stack_test.rb +0 -260
- data/test/multibyte.txt +0 -1
- data/test/options_test.rb +0 -333
- data/test/parameters_test.rb +0 -157
- data/test/request_middleware_test.rb +0 -126
- data/test/response_middleware_test.rb +0 -72
- data/test/strawberry.rb +0 -2
- data/test/utils_test.rb +0 -98
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "@technoweenie"
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-03-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multipart-post
|
@@ -42,6 +42,8 @@ files:
|
|
42
42
|
- LICENSE.md
|
43
43
|
- README.md
|
44
44
|
- Rakefile
|
45
|
+
- examples/client_spec.rb
|
46
|
+
- examples/client_test.rb
|
45
47
|
- lib/faraday.rb
|
46
48
|
- lib/faraday/adapter.rb
|
47
49
|
- lib/faraday/adapter/em_http.rb
|
@@ -56,12 +58,24 @@ files:
|
|
56
58
|
- lib/faraday/adapter/rack.rb
|
57
59
|
- lib/faraday/adapter/test.rb
|
58
60
|
- lib/faraday/adapter/typhoeus.rb
|
61
|
+
- lib/faraday/adapter_registry.rb
|
59
62
|
- lib/faraday/autoload.rb
|
60
63
|
- lib/faraday/connection.rb
|
61
|
-
- lib/faraday/
|
64
|
+
- lib/faraday/dependency_loader.rb
|
65
|
+
- lib/faraday/encoders/flat_params_encoder.rb
|
66
|
+
- lib/faraday/encoders/nested_params_encoder.rb
|
62
67
|
- lib/faraday/error.rb
|
68
|
+
- lib/faraday/file_part.rb
|
69
|
+
- lib/faraday/logging/formatter.rb
|
63
70
|
- lib/faraday/middleware.rb
|
71
|
+
- lib/faraday/middleware_registry.rb
|
64
72
|
- lib/faraday/options.rb
|
73
|
+
- lib/faraday/options/connection_options.rb
|
74
|
+
- lib/faraday/options/env.rb
|
75
|
+
- lib/faraday/options/proxy_options.rb
|
76
|
+
- lib/faraday/options/request_options.rb
|
77
|
+
- lib/faraday/options/ssl_options.rb
|
78
|
+
- lib/faraday/param_part.rb
|
65
79
|
- lib/faraday/parameters.rb
|
66
80
|
- lib/faraday/rack_builder.rb
|
67
81
|
- lib/faraday/request.rb
|
@@ -75,65 +89,79 @@ files:
|
|
75
89
|
- lib/faraday/response.rb
|
76
90
|
- lib/faraday/response/logger.rb
|
77
91
|
- lib/faraday/response/raise_error.rb
|
78
|
-
- lib/faraday/upload_io.rb
|
79
92
|
- lib/faraday/utils.rb
|
80
|
-
-
|
93
|
+
- lib/faraday/utils/headers.rb
|
94
|
+
- lib/faraday/utils/params_hash.rb
|
95
|
+
- spec/external_adapters/faraday_specs_setup.rb
|
96
|
+
- spec/faraday/adapter/em_http_spec.rb
|
97
|
+
- spec/faraday/adapter/em_synchrony_spec.rb
|
98
|
+
- spec/faraday/adapter/excon_spec.rb
|
99
|
+
- spec/faraday/adapter/httpclient_spec.rb
|
100
|
+
- spec/faraday/adapter/net_http_persistent_spec.rb
|
101
|
+
- spec/faraday/adapter/net_http_spec.rb
|
102
|
+
- spec/faraday/adapter/patron_spec.rb
|
103
|
+
- spec/faraday/adapter/rack_spec.rb
|
104
|
+
- spec/faraday/adapter/typhoeus_spec.rb
|
105
|
+
- spec/faraday/adapter_registry_spec.rb
|
106
|
+
- spec/faraday/adapter_spec.rb
|
107
|
+
- spec/faraday/composite_read_io_spec.rb
|
108
|
+
- spec/faraday/connection_spec.rb
|
81
109
|
- spec/faraday/error_spec.rb
|
110
|
+
- spec/faraday/middleware_spec.rb
|
111
|
+
- spec/faraday/options/env_spec.rb
|
112
|
+
- spec/faraday/options/options_spec.rb
|
113
|
+
- spec/faraday/options/proxy_options_spec.rb
|
114
|
+
- spec/faraday/options/request_options_spec.rb
|
115
|
+
- spec/faraday/params_encoders/flat_spec.rb
|
116
|
+
- spec/faraday/params_encoders/nested_spec.rb
|
117
|
+
- spec/faraday/rack_builder_spec.rb
|
118
|
+
- spec/faraday/request/authorization_spec.rb
|
119
|
+
- spec/faraday/request/instrumentation_spec.rb
|
120
|
+
- spec/faraday/request/multipart_spec.rb
|
121
|
+
- spec/faraday/request/retry_spec.rb
|
122
|
+
- spec/faraday/request/url_encoded_spec.rb
|
123
|
+
- spec/faraday/request_spec.rb
|
124
|
+
- spec/faraday/response/logger_spec.rb
|
125
|
+
- spec/faraday/response/middleware_spec.rb
|
82
126
|
- spec/faraday/response/raise_error_spec.rb
|
127
|
+
- spec/faraday/response_spec.rb
|
128
|
+
- spec/faraday/utils/headers_spec.rb
|
129
|
+
- spec/faraday/utils_spec.rb
|
130
|
+
- spec/faraday_spec.rb
|
83
131
|
- spec/spec_helper.rb
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
- test/adapters/net_http_test.rb
|
93
|
-
- test/adapters/patron_test.rb
|
94
|
-
- test/adapters/rack_test.rb
|
95
|
-
- test/adapters/test_middleware_test.rb
|
96
|
-
- test/adapters/typhoeus_test.rb
|
97
|
-
- test/authentication_middleware_test.rb
|
98
|
-
- test/composite_read_io_test.rb
|
99
|
-
- test/connection_test.rb
|
100
|
-
- test/env_test.rb
|
101
|
-
- test/helper.rb
|
102
|
-
- test/live_server.rb
|
103
|
-
- test/middleware/instrumentation_test.rb
|
104
|
-
- test/middleware/retry_test.rb
|
105
|
-
- test/middleware_stack_test.rb
|
106
|
-
- test/multibyte.txt
|
107
|
-
- test/options_test.rb
|
108
|
-
- test/parameters_test.rb
|
109
|
-
- test/request_middleware_test.rb
|
110
|
-
- test/response_middleware_test.rb
|
111
|
-
- test/strawberry.rb
|
112
|
-
- test/utils_test.rb
|
132
|
+
- spec/support/disabling_stub.rb
|
133
|
+
- spec/support/fake_safe_buffer.rb
|
134
|
+
- spec/support/helper_methods.rb
|
135
|
+
- spec/support/shared_examples/adapter.rb
|
136
|
+
- spec/support/shared_examples/params_encoder.rb
|
137
|
+
- spec/support/shared_examples/request_method.rb
|
138
|
+
- spec/support/streaming_response_checker.rb
|
139
|
+
- spec/support/webmock_rack_app.rb
|
113
140
|
homepage: https://lostisland.github.io/faraday
|
114
141
|
licenses:
|
115
142
|
- MIT
|
116
143
|
metadata:
|
117
144
|
homepage_uri: https://lostisland.github.io/faraday
|
118
|
-
changelog_uri: https://github.com/lostisland/faraday/
|
119
|
-
source_code_uri: https://github.com/lostisland/faraday
|
145
|
+
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v1.0.1
|
146
|
+
source_code_uri: https://github.com/lostisland/faraday
|
120
147
|
bug_tracker_uri: https://github.com/lostisland/faraday/issues
|
121
148
|
post_install_message:
|
122
149
|
rdoc_options: []
|
123
150
|
require_paths:
|
124
151
|
- lib
|
152
|
+
- spec/external_adapters
|
125
153
|
required_ruby_version: !ruby/object:Gem::Requirement
|
126
154
|
requirements:
|
127
155
|
- - ">="
|
128
156
|
- !ruby/object:Gem::Version
|
129
|
-
version: '
|
157
|
+
version: '2.3'
|
130
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
159
|
requirements:
|
132
160
|
- - ">="
|
133
161
|
- !ruby/object:Gem::Version
|
134
162
|
version: '0'
|
135
163
|
requirements: []
|
136
|
-
rubygems_version: 3.3
|
164
|
+
rubygems_version: 3.0.3
|
137
165
|
signing_key:
|
138
166
|
specification_version: 4
|
139
167
|
summary: HTTP/REST API client library.
|
data/lib/faraday/deprecate.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Faraday
|
4
|
-
# @param new_klass [Class] new Klass to use
|
5
|
-
#
|
6
|
-
# @return [Class] A modified version of new_klass that warns on
|
7
|
-
# usage about deprecation.
|
8
|
-
# @see Faraday::Deprecate
|
9
|
-
module DeprecatedClass
|
10
|
-
def self.proxy_class(origclass, ver = '1.0')
|
11
|
-
proxy = Class.new(origclass) do
|
12
|
-
const_set("ORIG_CLASS", origclass)
|
13
|
-
|
14
|
-
class << self
|
15
|
-
extend Faraday::Deprecate
|
16
|
-
|
17
|
-
def ===(other)
|
18
|
-
(superclass == const_get("ORIG_CLASS") && other.is_a?(superclass)) || super
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
proxy.singleton_class.send(:deprecate, :new, "#{origclass}.new", ver)
|
23
|
-
proxy.singleton_class.send(:deprecate, :inherited, origclass.name, ver)
|
24
|
-
proxy
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Deprecation using semver instead of date, based on Gem::Deprecate
|
29
|
-
# Provides a single method +deprecate+ to be used to declare when
|
30
|
-
# something is going away.
|
31
|
-
#
|
32
|
-
# class Legacy
|
33
|
-
# def self.klass_method
|
34
|
-
# # ...
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# def instance_method
|
38
|
-
# # ...
|
39
|
-
# end
|
40
|
-
#
|
41
|
-
# extend Faraday::Deprecate
|
42
|
-
# deprecate :instance_method, "X.z", '1.0'
|
43
|
-
#
|
44
|
-
# class << self
|
45
|
-
# extend Faraday::Deprecate
|
46
|
-
# deprecate :klass_method, :none, '1.0'
|
47
|
-
# end
|
48
|
-
# end
|
49
|
-
module Deprecate
|
50
|
-
def self.skip # :nodoc:
|
51
|
-
@skip ||= begin
|
52
|
-
case ENV['FARADAY_DEPRECATE'].to_s.downcase
|
53
|
-
when '1', 'warn' then :warn
|
54
|
-
else :skip
|
55
|
-
end
|
56
|
-
end
|
57
|
-
@skip == :skip
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.skip=(value) # :nodoc:
|
61
|
-
@skip = value ? :skip : :warn
|
62
|
-
end
|
63
|
-
|
64
|
-
# Temporarily turn off warnings. Intended for tests only.
|
65
|
-
def skip_during
|
66
|
-
original = Faraday::Deprecate.skip
|
67
|
-
Faraday::Deprecate.skip, = true
|
68
|
-
yield
|
69
|
-
ensure
|
70
|
-
Faraday::Deprecate.skip = original
|
71
|
-
end
|
72
|
-
|
73
|
-
# Simple deprecation method that deprecates +name+ by wrapping it up
|
74
|
-
# in a dummy method. It warns on each call to the dummy method
|
75
|
-
# telling the user of +repl+ (unless +repl+ is :none) and the
|
76
|
-
# semver that it is planned to go away.
|
77
|
-
# @param name [Symbol] the method symbol to deprecate
|
78
|
-
# @param repl [#to_s, :none] the replacement to use, when `:none` it will
|
79
|
-
# alert the user that no replacemtent is present.
|
80
|
-
# @param ver [String] the semver the method will be removed.
|
81
|
-
def deprecate(name, repl, ver)
|
82
|
-
class_eval do
|
83
|
-
gem_ver = Gem::Version.new(ver)
|
84
|
-
old = "_deprecated_#{name}"
|
85
|
-
alias_method old, name
|
86
|
-
define_method name do |*args, &block|
|
87
|
-
mod = is_a? Module
|
88
|
-
target = mod ? "#{self}." : "#{self.class}#"
|
89
|
-
target_message = if name == :inherited
|
90
|
-
"Inheriting #{self}"
|
91
|
-
else
|
92
|
-
"#{target}#{name}"
|
93
|
-
end
|
94
|
-
|
95
|
-
msg = [
|
96
|
-
"NOTE: #{target_message} is deprecated",
|
97
|
-
repl == :none ? ' with no replacement' : "; use #{repl} instead. ",
|
98
|
-
"It will be removed in or after version #{gem_ver}",
|
99
|
-
"\n#{target}#{name} called from #{Gem.location_of_caller.join(':')}"
|
100
|
-
]
|
101
|
-
warn "#{msg.join}." unless Faraday::Deprecate.skip
|
102
|
-
send old, *args, &block
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
module_function :deprecate, :skip_during
|
108
|
-
end
|
109
|
-
end
|
data/lib/faraday/upload_io.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'multipart/post'
|
3
|
-
require 'stringio'
|
4
|
-
rescue LoadError
|
5
|
-
begin
|
6
|
-
require 'composite_io'
|
7
|
-
require 'parts'
|
8
|
-
require 'stringio'
|
9
|
-
rescue LoadError
|
10
|
-
$stderr.puts "Install the multipart-post gem."
|
11
|
-
raise
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
module Faraday
|
16
|
-
# Similar but not compatible with ::CompositeReadIO provided by multipart-post.
|
17
|
-
class CompositeReadIO
|
18
|
-
def initialize(*parts)
|
19
|
-
@parts = parts.flatten
|
20
|
-
@ios = @parts.map { |part| part.to_io }
|
21
|
-
@index = 0
|
22
|
-
end
|
23
|
-
|
24
|
-
def length
|
25
|
-
@parts.inject(0) { |sum, part| sum + part.length }
|
26
|
-
end
|
27
|
-
|
28
|
-
def rewind
|
29
|
-
@ios.each { |io| io.rewind }
|
30
|
-
@index = 0
|
31
|
-
end
|
32
|
-
|
33
|
-
# Read from IOs in order until `length` bytes have been received.
|
34
|
-
def read(length = nil, outbuf = nil)
|
35
|
-
got_result = false
|
36
|
-
outbuf = outbuf ? outbuf.replace("") : ""
|
37
|
-
|
38
|
-
while io = current_io
|
39
|
-
if result = io.read(length)
|
40
|
-
got_result ||= !result.nil?
|
41
|
-
result.force_encoding("BINARY") if result.respond_to?(:force_encoding)
|
42
|
-
outbuf << result
|
43
|
-
length -= result.length if length
|
44
|
-
break if length == 0
|
45
|
-
end
|
46
|
-
advance_io
|
47
|
-
end
|
48
|
-
(!got_result && length) ? nil : outbuf
|
49
|
-
end
|
50
|
-
|
51
|
-
def close
|
52
|
-
@ios.each { |io| io.close }
|
53
|
-
end
|
54
|
-
|
55
|
-
def ensure_open_and_readable
|
56
|
-
# Rubinius compatibility
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def current_io
|
62
|
-
@ios[@index]
|
63
|
-
end
|
64
|
-
|
65
|
-
def advance_io
|
66
|
-
@index += 1
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
if defined?(::Multipart::Post::UploadIO)
|
71
|
-
UploadIO = ::Multipart::Post::UploadIO
|
72
|
-
Parts = ::Multipart::Post::Parts
|
73
|
-
else
|
74
|
-
UploadIO = ::UploadIO
|
75
|
-
Parts = ::Parts
|
76
|
-
end
|
77
|
-
end
|
@@ -1,147 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe Faraday::DeprecatedClass do
|
4
|
-
class SampleClass < StandardError
|
5
|
-
attr_accessor :foo
|
6
|
-
|
7
|
-
def initialize(foo = nil)
|
8
|
-
@foo = foo || :foo
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
SampleDeprecatedClass = Faraday::DeprecatedClass.proxy_class(SampleClass)
|
13
|
-
|
14
|
-
it 'does not raise error for deprecated classes but prints an error message' do
|
15
|
-
error_message, foobar = with_warn_squelching { SampleDeprecatedClass.new(:foo_bar) }
|
16
|
-
expect(foobar).to be_a(SampleClass)
|
17
|
-
expect(foobar.foo).to eq(:foo_bar)
|
18
|
-
expect(error_message).to match(
|
19
|
-
Regexp.new(
|
20
|
-
'NOTE: SampleDeprecatedClass.new is deprecated; '\
|
21
|
-
'use SampleClass.new instead. It will be removed in or after version 1.0'
|
22
|
-
)
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'does not raise an error for inherited error-namespaced classes but prints an error message' do
|
27
|
-
error_message, = with_warn_squelching { Class.new(SampleDeprecatedClass) }
|
28
|
-
|
29
|
-
expect(error_message).to match(
|
30
|
-
Regexp.new(
|
31
|
-
'NOTE: Inheriting SampleDeprecatedClass is deprecated; '\
|
32
|
-
'use SampleClass instead. It will be removed in or after version 1.0'
|
33
|
-
)
|
34
|
-
)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'allows backward-compatible class to be subclassed' do
|
38
|
-
expect {
|
39
|
-
with_warn_squelching { Class.new(SampleDeprecatedClass) }
|
40
|
-
}.not_to raise_error
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'allows rescuing of a current error with a deprecated error' do
|
44
|
-
expect { raise SampleClass, nil }.to raise_error(SampleDeprecatedClass)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'allows rescuing of a current error with a current error' do
|
48
|
-
expect { raise SampleClass, nil }.to raise_error(SampleClass)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'allows rescuing of a deprecated error with a deprecated error' do
|
52
|
-
expect { raise SampleDeprecatedClass, nil }.to raise_error(SampleDeprecatedClass)
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'allows rescuing of a deprecated error with a current error' do
|
56
|
-
expect { raise SampleDeprecatedClass, nil }.to raise_error(SampleClass)
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'match behavior' do
|
60
|
-
class SampleDeprecatedClassA < SampleDeprecatedClass; end
|
61
|
-
class SampleDeprecatedClassB < SampleDeprecatedClass; end
|
62
|
-
|
63
|
-
class SampleDeprecatedClassAX < SampleDeprecatedClassA; end
|
64
|
-
|
65
|
-
class SampleClassA < SampleClass; end
|
66
|
-
|
67
|
-
describe 'undeprecated class' do
|
68
|
-
it 'is === to instance of deprecated class' do
|
69
|
-
expect(SampleClass === SampleDeprecatedClass.new).to be true
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'is === to instance of subclass of deprecated class' do
|
73
|
-
expect(SampleClass === SampleDeprecatedClassA.new).to be true
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'is === to instance of subclass of subclass of deprecated class' do
|
77
|
-
expect(SampleClass === SampleDeprecatedClassAX.new).to be true
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe 'subclass of undeprecated class' do
|
82
|
-
it 'is not === to instance of undeprecated class' do
|
83
|
-
expect(SampleClassA === SampleClass.new).to be false
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'is not === to instance of deprecated class' do
|
87
|
-
expect(SampleClassA === SampleDeprecatedClass.new).to be false
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe 'deprecated class' do
|
92
|
-
it 'is === to instance of undeprecated class' do
|
93
|
-
expect(SampleDeprecatedClass === SampleClass.new).to be true
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'is === to instance of subclass of undeprecated class' do
|
97
|
-
expect(SampleDeprecatedClass === SampleClassA.new).to be true
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'is === to instance of subclass of deprecated class' do
|
101
|
-
expect(SampleDeprecatedClass === SampleDeprecatedClassA.new).to be true
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'is === to instance of subclass of subclass of deprecated class' do
|
105
|
-
expect(SampleDeprecatedClass === SampleDeprecatedClassAX.new).to be true
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe 'subclass of deprecated class' do
|
110
|
-
it 'is not === to instance of subclass of undeprecated class' do
|
111
|
-
expect(SampleDeprecatedClassA === SampleClass.new).to be false
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'is not === to instance of another subclass of deprecated class' do
|
115
|
-
expect(SampleDeprecatedClassA === SampleDeprecatedClassB.new).to be false
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'is === to instance of its subclass' do
|
119
|
-
expect(SampleDeprecatedClassA === SampleDeprecatedClassAX.new).to be true
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'is === to instance of deprecated class' do
|
123
|
-
expect(SampleDeprecatedClass === SampleDeprecatedClassB.new).to be true
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe 'subclass of subclass of deprecated class' do
|
128
|
-
it 'is not === to instance of subclass of another subclass of deprecated class' do
|
129
|
-
expect(SampleDeprecatedClassAX === SampleDeprecatedClassB.new).to be false
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'is not === to instance of its superclass' do
|
133
|
-
expect(SampleDeprecatedClassA === SampleDeprecatedClass.new).to be false
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
def with_warn_squelching
|
139
|
-
stderr_catcher = StringIO.new
|
140
|
-
original_stderr = $stderr
|
141
|
-
$stderr = stderr_catcher
|
142
|
-
result = yield if block_given?
|
143
|
-
[stderr_catcher.tap(&:rewind).string, result]
|
144
|
-
ensure
|
145
|
-
$stderr = original_stderr
|
146
|
-
end
|
147
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require File.expand_path('../integration', __FILE__)
|
2
|
-
|
3
|
-
module Adapters
|
4
|
-
class DefaultTest < Faraday::TestCase
|
5
|
-
|
6
|
-
def adapter() :default end
|
7
|
-
|
8
|
-
Integration.apply(self, :NonParallel) do
|
9
|
-
# default stack is not configured with Multipart
|
10
|
-
undef :test_POST_sends_files
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.expand_path('../integration', __FILE__)
|
2
|
-
|
3
|
-
module Adapters
|
4
|
-
class EMHttpTest < Faraday::TestCase
|
5
|
-
|
6
|
-
def adapter() :em_http end
|
7
|
-
|
8
|
-
Integration.apply(self, :Parallel) do
|
9
|
-
# https://github.com/eventmachine/eventmachine/pull/289
|
10
|
-
undef :test_timeout
|
11
|
-
|
12
|
-
def test_binds_local_socket
|
13
|
-
host = '1.2.3.4'
|
14
|
-
conn = create_connection :request => { :bind => { :host => host } }
|
15
|
-
assert_equal host, conn.options[:bind][:host]
|
16
|
-
end
|
17
|
-
end unless jruby? and ssl_mode?
|
18
|
-
# https://github.com/eventmachine/eventmachine/issues/180
|
19
|
-
|
20
|
-
def test_custom_adapter_config
|
21
|
-
url = URI('https://example.com:1234')
|
22
|
-
|
23
|
-
adapter = Faraday::Adapter::EMHttp.new nil, inactivity_timeout: 20
|
24
|
-
|
25
|
-
req = adapter.create_request(url: url, request: {})
|
26
|
-
|
27
|
-
assert_equal 20, req.connopts.inactivity_timeout
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.expand_path('../integration', __FILE__)
|
2
|
-
|
3
|
-
module Adapters
|
4
|
-
class EMSynchronyTest < Faraday::TestCase
|
5
|
-
|
6
|
-
def adapter() :em_synchrony end
|
7
|
-
|
8
|
-
unless jruby?
|
9
|
-
Integration.apply(self, :Parallel) do
|
10
|
-
# https://github.com/eventmachine/eventmachine/pull/289
|
11
|
-
undef :test_timeout
|
12
|
-
|
13
|
-
def test_binds_local_socket
|
14
|
-
host = '1.2.3.4'
|
15
|
-
conn = create_connection :request => { :bind => { :host => host } }
|
16
|
-
#put conn.get('/who-am-i').body
|
17
|
-
assert_equal host, conn.options[:bind][:host]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_custom_adapter_config
|
23
|
-
url = URI('https://example.com:1234')
|
24
|
-
|
25
|
-
adapter = Faraday::Adapter::EMSynchrony.new nil, inactivity_timeout: 20
|
26
|
-
|
27
|
-
req = adapter.create_request(url: url, request: {})
|
28
|
-
|
29
|
-
assert_equal 20, req.connopts.inactivity_timeout
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/test/adapters/excon_test.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.expand_path('../integration', __FILE__)
|
2
|
-
|
3
|
-
module Adapters
|
4
|
-
class ExconTest < Faraday::TestCase
|
5
|
-
|
6
|
-
def adapter() :excon end
|
7
|
-
|
8
|
-
Integration.apply(self, :NonParallel) do
|
9
|
-
# https://github.com/geemus/excon/issues/126 ?
|
10
|
-
undef :test_timeout if ssl_mode?
|
11
|
-
|
12
|
-
# Excon lets OpenSSL::SSL::SSLError be raised without any way to
|
13
|
-
# distinguish whether it happened because of a 407 proxy response
|
14
|
-
undef :test_proxy_auth_fail if ssl_mode?
|
15
|
-
|
16
|
-
# https://github.com/geemus/excon/issues/358
|
17
|
-
undef :test_connection_error if RUBY_VERSION >= '2.1.0'
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_custom_adapter_config
|
21
|
-
url = URI('https://example.com:1234')
|
22
|
-
|
23
|
-
adapter = Faraday::Adapter::Excon.new nil, debug_request: true
|
24
|
-
|
25
|
-
conn = adapter.create_connection({url: url}, {})
|
26
|
-
|
27
|
-
assert_equal true, conn.data[:debug_request]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require File.expand_path('../integration', __FILE__)
|
2
|
-
|
3
|
-
module Adapters
|
4
|
-
class HttpclientTest < Faraday::TestCase
|
5
|
-
|
6
|
-
def adapter() :httpclient end
|
7
|
-
|
8
|
-
Integration.apply(self, :NonParallel, :Compression) do
|
9
|
-
def setup
|
10
|
-
require 'httpclient' unless defined?(HTTPClient)
|
11
|
-
HTTPClient::NO_PROXY_HOSTS.delete('localhost')
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_binds_local_socket
|
15
|
-
host = '1.2.3.4'
|
16
|
-
conn = create_connection :request => { :bind => { :host => host } }
|
17
|
-
assert_equal host, conn.options[:bind][:host]
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_custom_adapter_config
|
21
|
-
adapter = Faraday::Adapter::HTTPClient.new do |client|
|
22
|
-
client.keep_alive_timeout = 20
|
23
|
-
client.ssl_config.timeout = 25
|
24
|
-
end
|
25
|
-
|
26
|
-
client = adapter.client
|
27
|
-
adapter.configure_client
|
28
|
-
|
29
|
-
assert_equal 20, client.keep_alive_timeout
|
30
|
-
assert_equal 25, client.ssl_config.timeout
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|