faraday 2.12.2 → 2.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/faraday/error.rb +38 -4
- data/lib/faraday/options/env.rb +1 -1
- data/lib/faraday/options/proxy_options.rb +4 -2
- data/lib/faraday/options/ssl_options.rb +4 -1
- data/lib/faraday/rack_builder.rb +6 -9
- data/lib/faraday/response/logger.rb +5 -3
- data/lib/faraday/version.rb +1 -1
- data/lib/faraday.rb +2 -1
- data/spec/faraday/error_spec.rb +83 -1
- data/spec/faraday/options/proxy_options_spec.rb +27 -0
- data/spec/faraday/response/logger_spec.rb +19 -4
- data/spec/faraday/response/raise_error_spec.rb +10 -10
- data/spec/faraday/utils_spec.rb +1 -0
- metadata +4 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12dedb476a26ae00e5f902e4e10f5327a790290d2d7647711aac09e8661af959
|
4
|
+
data.tar.gz: f43c7bb1127b0a57bb7aa0727a096e0b66cfeead93445631dacf151c354efbdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3cb808ea984cc306ad71fc502bf79541d5e79fb9ca066784e0674dc71a2dc22ac20b6968065cceaa3fe5ccb909124aeef9513a37bf83bbcb4a63e116dbd6afe
|
7
|
+
data.tar.gz: 1540d3fe594b1d0a025caede980b99419de50d4ea148b53bf5cf7a3082307982c0917fd739621805252f8016e427ffdbfba59da5a679b529380adf0100cf10ef
|
data/lib/faraday/error.rb
CHANGED
@@ -79,12 +79,46 @@ module Faraday
|
|
79
79
|
|
80
80
|
# Pulls out potential parent exception and response hash.
|
81
81
|
def exc_msg_and_response(exc, response = nil)
|
82
|
-
|
82
|
+
case exc
|
83
|
+
when Exception
|
84
|
+
[exc, exc.message, response]
|
85
|
+
when Hash
|
86
|
+
[nil, build_error_message_from_hash(exc), exc]
|
87
|
+
when Faraday::Env
|
88
|
+
[nil, build_error_message_from_env(exc), exc]
|
89
|
+
else
|
90
|
+
[nil, exc.to_s, response]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def build_error_message_from_hash(hash)
|
97
|
+
# Be defensive with external Hash objects - they might be missing keys
|
98
|
+
status = hash.fetch(:status, nil)
|
99
|
+
request = hash.fetch(:request, nil)
|
100
|
+
|
101
|
+
return fallback_error_message(status) if request.nil?
|
83
102
|
|
84
|
-
|
85
|
-
|
103
|
+
method = request.fetch(:method, nil)
|
104
|
+
url = request.fetch(:url, nil)
|
105
|
+
build_status_error_message(status, method, url)
|
106
|
+
end
|
107
|
+
|
108
|
+
def build_error_message_from_env(env)
|
109
|
+
# Faraday::Env is internal - we can make reasonable assumptions about its structure
|
110
|
+
build_status_error_message(env.status, env.method, env.url)
|
111
|
+
end
|
112
|
+
|
113
|
+
def build_status_error_message(status, method, url)
|
114
|
+
method_str = method ? method.to_s.upcase : ''
|
115
|
+
url_str = url ? url.to_s : ''
|
116
|
+
"the server responded with status #{status} for #{method_str} #{url_str}"
|
117
|
+
end
|
86
118
|
|
87
|
-
|
119
|
+
def fallback_error_message(status)
|
120
|
+
"the server responded with status #{status} - method and url are not available " \
|
121
|
+
'due to include_request: false on Faraday::Response::RaiseError middleware'
|
88
122
|
end
|
89
123
|
end
|
90
124
|
|
data/lib/faraday/options/env.rb
CHANGED
@@ -60,7 +60,7 @@ module Faraday
|
|
60
60
|
:reason_phrase, :response_body) do
|
61
61
|
const_set(:ContentLength, 'Content-Length')
|
62
62
|
const_set(:StatusesWithoutBody, Set.new([204, 304]))
|
63
|
-
const_set(:SuccessfulStatuses,
|
63
|
+
const_set(:SuccessfulStatuses, 200..299)
|
64
64
|
|
65
65
|
# A Set of HTTP verbs that typically send a body. If no body is set for
|
66
66
|
# these requests, the Content-Length header is set to 0.
|
@@ -22,8 +22,10 @@ module Faraday
|
|
22
22
|
when URI
|
23
23
|
value = { uri: value }
|
24
24
|
when Hash, Options
|
25
|
-
if
|
26
|
-
value
|
25
|
+
if value[:uri]
|
26
|
+
value = value.dup.tap do |duped|
|
27
|
+
duped[:uri] = Utils.URI(duped[:uri])
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
@@ -11,6 +11,9 @@ module Faraday
|
|
11
11
|
# # @return [Boolean] whether to enable hostname verification on server certificates
|
12
12
|
# # during the handshake or not (see https://github.com/ruby/openssl/pull/60)
|
13
13
|
# #
|
14
|
+
# # @!attribute hostname
|
15
|
+
# # @return [String] Server hostname used for SNI (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL/SSLSocket.html#method-i-hostname-3D)
|
16
|
+
# #
|
14
17
|
# # @!attribute ca_file
|
15
18
|
# # @return [String] CA file
|
16
19
|
# #
|
@@ -50,7 +53,7 @@ module Faraday
|
|
50
53
|
# # @!attribute ciphers
|
51
54
|
# # @return [String] cipher list in OpenSSL format (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html#method-i-ciphers-3D)
|
52
55
|
# class SSLOptions < Options; end
|
53
|
-
SSLOptions = Options.new(:verify, :verify_hostname,
|
56
|
+
SSLOptions = Options.new(:verify, :verify_hostname, :hostname,
|
54
57
|
:ca_file, :ca_path, :verify_mode,
|
55
58
|
:cert_store, :client_cert, :client_key,
|
56
59
|
:certificate, :private_key, :verify_depth,
|
data/lib/faraday/rack_builder.rb
CHANGED
@@ -27,10 +27,11 @@ module Faraday
|
|
27
27
|
|
28
28
|
attr_reader :name
|
29
29
|
|
30
|
-
|
30
|
+
def initialize(klass, *args, **kwargs, &block)
|
31
31
|
@name = klass.to_s
|
32
32
|
REGISTRY.set(klass) if klass.respond_to?(:name)
|
33
33
|
@args = args
|
34
|
+
@kwargs = kwargs
|
34
35
|
@block = block
|
35
36
|
end
|
36
37
|
|
@@ -53,7 +54,7 @@ module Faraday
|
|
53
54
|
end
|
54
55
|
|
55
56
|
def build(app = nil)
|
56
|
-
klass.new(app, *@args, &@block)
|
57
|
+
klass.new(app, *@args, **@kwargs, &@block)
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
@@ -106,11 +107,11 @@ module Faraday
|
|
106
107
|
use_symbol(Faraday::Response, ...)
|
107
108
|
end
|
108
109
|
|
109
|
-
|
110
|
+
def adapter(klass = NO_ARGUMENT, *args, **kwargs, &block)
|
110
111
|
return @adapter if klass == NO_ARGUMENT || klass.nil?
|
111
112
|
|
112
113
|
klass = Faraday::Adapter.lookup_middleware(klass) if klass.is_a?(Symbol)
|
113
|
-
@adapter = self.class::Handler.new(klass, *args, &block)
|
114
|
+
@adapter = self.class::Handler.new(klass, *args, **kwargs, &block)
|
114
115
|
end
|
115
116
|
|
116
117
|
## methods to push onto the various positions in the stack:
|
@@ -220,7 +221,7 @@ module Faraday
|
|
220
221
|
end
|
221
222
|
|
222
223
|
def raise_if_adapter(klass)
|
223
|
-
return unless
|
224
|
+
return unless klass <= Faraday::Adapter
|
224
225
|
|
225
226
|
raise 'Adapter should be set using the `adapter` method, not `use`'
|
226
227
|
end
|
@@ -233,10 +234,6 @@ module Faraday
|
|
233
234
|
!@adapter.nil?
|
234
235
|
end
|
235
236
|
|
236
|
-
def is_adapter?(klass) # rubocop:disable Naming/PredicateName
|
237
|
-
klass <= Faraday::Adapter
|
238
|
-
end
|
239
|
-
|
240
237
|
def use_symbol(mod, key, ...)
|
241
238
|
use(mod.lookup_middleware(key), ...)
|
242
239
|
end
|
@@ -10,11 +10,13 @@ module Faraday
|
|
10
10
|
# lifecycle to a given Logger object. By default, this logs to STDOUT. See
|
11
11
|
# Faraday::Logging::Formatter to see specifically what is logged.
|
12
12
|
class Logger < Middleware
|
13
|
+
DEFAULT_OPTIONS = { formatter: Logging::Formatter }.merge(Logging::Formatter::DEFAULT_OPTIONS).freeze
|
14
|
+
|
13
15
|
def initialize(app, logger = nil, options = {})
|
14
|
-
super(app)
|
16
|
+
super(app, options)
|
15
17
|
logger ||= ::Logger.new($stdout)
|
16
|
-
formatter_class = options.delete(:formatter)
|
17
|
-
@formatter = formatter_class.new(logger: logger, options: options)
|
18
|
+
formatter_class = @options.delete(:formatter)
|
19
|
+
@formatter = formatter_class.new(logger: logger, options: @options)
|
18
20
|
yield @formatter if block_given?
|
19
21
|
end
|
20
22
|
|
data/lib/faraday/version.rb
CHANGED
data/lib/faraday.rb
CHANGED
data/spec/faraday/error_spec.rb
CHANGED
@@ -23,7 +23,7 @@ RSpec.describe Faraday::Error do
|
|
23
23
|
|
24
24
|
it { expect(subject.wrapped_exception).to be_nil }
|
25
25
|
it { expect(subject.response).to eq(exception) }
|
26
|
-
it { expect(subject.message).to eq('the server responded with status 400') }
|
26
|
+
it { expect(subject.message).to eq('the server responded with status 400 - method and url are not available due to include_request: false on Faraday::Response::RaiseError middleware') }
|
27
27
|
if RUBY_VERSION >= '3.4'
|
28
28
|
it { expect(subject.inspect).to eq('#<Faraday::Error response={status: 400}>') }
|
29
29
|
else
|
@@ -89,5 +89,87 @@ RSpec.describe Faraday::Error do
|
|
89
89
|
it { expect(subject.response_headers).to eq(headers) }
|
90
90
|
it { expect(subject.response_body).to eq(body) }
|
91
91
|
end
|
92
|
+
|
93
|
+
context 'with hash missing status key' do
|
94
|
+
let(:exception) { { body: 'error body' } }
|
95
|
+
|
96
|
+
it { expect(subject.wrapped_exception).to be_nil }
|
97
|
+
it { expect(subject.response).to eq(exception) }
|
98
|
+
it { expect(subject.message).to eq('the server responded with status - method and url are not available due to include_request: false on Faraday::Response::RaiseError middleware') }
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'with hash with status but missing request data' do
|
102
|
+
let(:exception) { { status: 404, body: 'not found' } } # missing request key
|
103
|
+
|
104
|
+
it { expect(subject.wrapped_exception).to be_nil }
|
105
|
+
it { expect(subject.response).to eq(exception) }
|
106
|
+
it { expect(subject.message).to eq('the server responded with status 404 - method and url are not available due to include_request: false on Faraday::Response::RaiseError middleware') }
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'with hash with status and request but missing method in request' do
|
110
|
+
let(:exception) { { status: 404, body: 'not found', request: { url: 'http://example.com/test' } } } # missing method
|
111
|
+
|
112
|
+
it { expect(subject.wrapped_exception).to be_nil }
|
113
|
+
it { expect(subject.response).to eq(exception) }
|
114
|
+
it { expect(subject.message).to eq('the server responded with status 404 for http://example.com/test') }
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'with hash with status and request but missing url in request' do
|
118
|
+
let(:exception) { { status: 404, body: 'not found', request: { method: :get } } } # missing url
|
119
|
+
|
120
|
+
it { expect(subject.wrapped_exception).to be_nil }
|
121
|
+
it { expect(subject.response).to eq(exception) }
|
122
|
+
it { expect(subject.message).to eq('the server responded with status 404 for GET ') }
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'with properly formed Faraday::Env' do
|
126
|
+
# This represents the normal case - a well-formed Faraday::Env object
|
127
|
+
# with all the standard properties populated as they would be during
|
128
|
+
# a typical HTTP request/response cycle
|
129
|
+
let(:exception) { Faraday::Env.new }
|
130
|
+
|
131
|
+
before do
|
132
|
+
exception.status = 500
|
133
|
+
exception.method = :post
|
134
|
+
exception.url = URI('https://api.example.com/users')
|
135
|
+
exception.request = Faraday::RequestOptions.new
|
136
|
+
exception.response_headers = { 'content-type' => 'application/json' }
|
137
|
+
exception.response_body = '{"error": "Internal server error"}'
|
138
|
+
exception.request_headers = { 'authorization' => 'Bearer token123' }
|
139
|
+
exception.request_body = '{"name": "John"}'
|
140
|
+
end
|
141
|
+
|
142
|
+
it { expect(subject.wrapped_exception).to be_nil }
|
143
|
+
it { expect(subject.response).to eq(exception) }
|
144
|
+
it { expect(subject.message).to eq('the server responded with status 500 for POST https://api.example.com/users') }
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'with Faraday::Env missing status key' do
|
148
|
+
let(:exception) { Faraday::Env.new }
|
149
|
+
|
150
|
+
before do
|
151
|
+
exception[:body] = 'error body'
|
152
|
+
# Intentionally not setting status
|
153
|
+
end
|
154
|
+
|
155
|
+
it { expect(subject.wrapped_exception).to be_nil }
|
156
|
+
it { expect(subject.response).to eq(exception) }
|
157
|
+
it { expect(subject.message).to eq('the server responded with status for ') }
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'with Faraday::Env with direct method and url properties' do
|
161
|
+
let(:exception) { Faraday::Env.new }
|
162
|
+
|
163
|
+
before do
|
164
|
+
exception.status = 404
|
165
|
+
exception.method = :get
|
166
|
+
exception.url = URI('http://example.com/test')
|
167
|
+
exception[:body] = 'not found'
|
168
|
+
end
|
169
|
+
|
170
|
+
it { expect(subject.wrapped_exception).to be_nil }
|
171
|
+
it { expect(subject.response).to eq(exception) }
|
172
|
+
it { expect(subject.message).to eq('the server responded with status 404 for GET http://example.com/test') }
|
173
|
+
end
|
92
174
|
end
|
93
175
|
end
|
@@ -27,6 +27,33 @@ RSpec.describe Faraday::ProxyOptions do
|
|
27
27
|
expect(options.inspect).to eq('#<Faraday::ProxyOptions (empty)>')
|
28
28
|
end
|
29
29
|
|
30
|
+
it 'works with hash' do
|
31
|
+
hash = { user: 'user', password: 'pass', uri: 'http://@example.org' }
|
32
|
+
options = Faraday::ProxyOptions.from(hash)
|
33
|
+
expect(options.user).to eq('user')
|
34
|
+
expect(options.password).to eq('pass')
|
35
|
+
expect(options.uri).to be_a_kind_of(URI)
|
36
|
+
expect(options.path).to eq('')
|
37
|
+
expect(options.port).to eq(80)
|
38
|
+
expect(options.host).to eq('example.org')
|
39
|
+
expect(options.scheme).to eq('http')
|
40
|
+
expect(options.inspect).to match('#<Faraday::ProxyOptions uri=')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'works with option' do
|
44
|
+
opt_arg = { user: 'user', password: 'pass', uri: 'http://@example.org' }
|
45
|
+
option = Faraday::ConnectionOptions.from(proxy: opt_arg)
|
46
|
+
options = Faraday::ProxyOptions.from(option.proxy)
|
47
|
+
expect(options.user).to eq('user')
|
48
|
+
expect(options.password).to eq('pass')
|
49
|
+
expect(options.uri).to be_a_kind_of(URI)
|
50
|
+
expect(options.path).to eq('')
|
51
|
+
expect(options.port).to eq(80)
|
52
|
+
expect(options.host).to eq('example.org')
|
53
|
+
expect(options.scheme).to eq('http')
|
54
|
+
expect(options.inspect).to match('#<Faraday::ProxyOptions uri=')
|
55
|
+
end
|
56
|
+
|
30
57
|
it 'works with no auth' do
|
31
58
|
proxy = Faraday::ProxyOptions.from 'http://example.org'
|
32
59
|
expect(proxy.user).to be_nil
|
@@ -189,7 +189,7 @@ RSpec.describe Faraday::Response::Logger do
|
|
189
189
|
context 'when logging request body' do
|
190
190
|
let(:logger_options) { { bodies: { request: true } } }
|
191
191
|
|
192
|
-
it '
|
192
|
+
it 'logs only request body' do
|
193
193
|
conn.post '/ohyes', 'name=Tamago', accept: 'text/html'
|
194
194
|
expect(string_io.string).to match(%(name=Tamago))
|
195
195
|
expect(string_io.string).not_to match(%(pebbles))
|
@@ -199,7 +199,7 @@ RSpec.describe Faraday::Response::Logger do
|
|
199
199
|
context 'when logging response body' do
|
200
200
|
let(:logger_options) { { bodies: { response: true } } }
|
201
201
|
|
202
|
-
it '
|
202
|
+
it 'logs only response body' do
|
203
203
|
conn.post '/ohyes', 'name=Hamachi', accept: 'text/html'
|
204
204
|
expect(string_io.string).to match(%(pebbles))
|
205
205
|
expect(string_io.string).not_to match(%(name=Hamachi))
|
@@ -209,13 +209,13 @@ RSpec.describe Faraday::Response::Logger do
|
|
209
209
|
context 'when logging request and response bodies' do
|
210
210
|
let(:logger_options) { { bodies: true } }
|
211
211
|
|
212
|
-
it '
|
212
|
+
it 'logs request and response body' do
|
213
213
|
conn.post '/ohyes', 'name=Ebi', accept: 'text/html'
|
214
214
|
expect(string_io.string).to match(%(name=Ebi))
|
215
215
|
expect(string_io.string).to match(%(pebbles))
|
216
216
|
end
|
217
217
|
|
218
|
-
it '
|
218
|
+
it 'logs response body object' do
|
219
219
|
conn.get '/rubbles', nil, accept: 'text/html'
|
220
220
|
expect(string_io.string).to match(%([\"Barney\", \"Betty\", \"Bam Bam\"]\n))
|
221
221
|
end
|
@@ -228,6 +228,21 @@ RSpec.describe Faraday::Response::Logger do
|
|
228
228
|
end
|
229
229
|
end
|
230
230
|
|
231
|
+
context 'when bodies are logged by default' do
|
232
|
+
before do
|
233
|
+
described_class.default_options = { bodies: true }
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'logs response body' do
|
237
|
+
conn.post '/ohai'
|
238
|
+
expect(string_io.string).to match(%(fred))
|
239
|
+
end
|
240
|
+
|
241
|
+
after do
|
242
|
+
described_class.default_options = { bodies: false }
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
231
246
|
context 'when logging errors' do
|
232
247
|
let(:logger_options) { { errors: true } }
|
233
248
|
|
@@ -28,7 +28,7 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
28
28
|
|
29
29
|
it 'raises Faraday::BadRequestError for 400 responses' do
|
30
30
|
expect { conn.get('bad-request') }.to raise_error(Faraday::BadRequestError) do |ex|
|
31
|
-
expect(ex.message).to eq('the server responded with status 400')
|
31
|
+
expect(ex.message).to eq('the server responded with status 400 for GET http:/bad-request')
|
32
32
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
33
33
|
expect(ex.response[:status]).to eq(400)
|
34
34
|
expect(ex.response_status).to eq(400)
|
@@ -39,7 +39,7 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
39
39
|
|
40
40
|
it 'raises Faraday::UnauthorizedError for 401 responses' do
|
41
41
|
expect { conn.get('unauthorized') }.to raise_error(Faraday::UnauthorizedError) do |ex|
|
42
|
-
expect(ex.message).to eq('the server responded with status 401')
|
42
|
+
expect(ex.message).to eq('the server responded with status 401 for GET http:/unauthorized')
|
43
43
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
44
44
|
expect(ex.response[:status]).to eq(401)
|
45
45
|
expect(ex.response_status).to eq(401)
|
@@ -50,7 +50,7 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
50
50
|
|
51
51
|
it 'raises Faraday::ForbiddenError for 403 responses' do
|
52
52
|
expect { conn.get('forbidden') }.to raise_error(Faraday::ForbiddenError) do |ex|
|
53
|
-
expect(ex.message).to eq('the server responded with status 403')
|
53
|
+
expect(ex.message).to eq('the server responded with status 403 for GET http:/forbidden')
|
54
54
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
55
55
|
expect(ex.response[:status]).to eq(403)
|
56
56
|
expect(ex.response_status).to eq(403)
|
@@ -61,7 +61,7 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
61
61
|
|
62
62
|
it 'raises Faraday::ResourceNotFound for 404 responses' do
|
63
63
|
expect { conn.get('not-found') }.to raise_error(Faraday::ResourceNotFound) do |ex|
|
64
|
-
expect(ex.message).to eq('the server responded with status 404')
|
64
|
+
expect(ex.message).to eq('the server responded with status 404 for GET http:/not-found')
|
65
65
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
66
66
|
expect(ex.response[:status]).to eq(404)
|
67
67
|
expect(ex.response_status).to eq(404)
|
@@ -83,7 +83,7 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
83
83
|
|
84
84
|
it 'raises Faraday::RequestTimeoutError for 408 responses' do
|
85
85
|
expect { conn.get('request-timeout') }.to raise_error(Faraday::RequestTimeoutError) do |ex|
|
86
|
-
expect(ex.message).to eq('the server responded with status 408')
|
86
|
+
expect(ex.message).to eq('the server responded with status 408 for GET http:/request-timeout')
|
87
87
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
88
88
|
expect(ex.response[:status]).to eq(408)
|
89
89
|
expect(ex.response_status).to eq(408)
|
@@ -94,7 +94,7 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
94
94
|
|
95
95
|
it 'raises Faraday::ConflictError for 409 responses' do
|
96
96
|
expect { conn.get('conflict') }.to raise_error(Faraday::ConflictError) do |ex|
|
97
|
-
expect(ex.message).to eq('the server responded with status 409')
|
97
|
+
expect(ex.message).to eq('the server responded with status 409 for GET http:/conflict')
|
98
98
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
99
99
|
expect(ex.response[:status]).to eq(409)
|
100
100
|
expect(ex.response_status).to eq(409)
|
@@ -105,7 +105,7 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
105
105
|
|
106
106
|
it 'raises Faraday::UnprocessableEntityError for 422 responses' do
|
107
107
|
expect { conn.get('unprocessable-entity') }.to raise_error(Faraday::UnprocessableEntityError) do |ex|
|
108
|
-
expect(ex.message).to eq('the server responded with status 422')
|
108
|
+
expect(ex.message).to eq('the server responded with status 422 for GET http:/unprocessable-entity')
|
109
109
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
110
110
|
expect(ex.response[:status]).to eq(422)
|
111
111
|
expect(ex.response_status).to eq(422)
|
@@ -116,7 +116,7 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
116
116
|
|
117
117
|
it 'raises Faraday::TooManyRequestsError for 429 responses' do
|
118
118
|
expect { conn.get('too-many-requests') }.to raise_error(Faraday::TooManyRequestsError) do |ex|
|
119
|
-
expect(ex.message).to eq('the server responded with status 429')
|
119
|
+
expect(ex.message).to eq('the server responded with status 429 for GET http:/too-many-requests')
|
120
120
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
121
121
|
expect(ex.response[:status]).to eq(429)
|
122
122
|
expect(ex.response_status).to eq(429)
|
@@ -138,7 +138,7 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
138
138
|
|
139
139
|
it 'raises Faraday::ClientError for other 4xx responses' do
|
140
140
|
expect { conn.get('4xx') }.to raise_error(Faraday::ClientError) do |ex|
|
141
|
-
expect(ex.message).to eq('the server responded with status 499')
|
141
|
+
expect(ex.message).to eq('the server responded with status 499 for GET http:/4xx')
|
142
142
|
expect(ex.response[:headers]['X-Reason']).to eq('because')
|
143
143
|
expect(ex.response[:status]).to eq(499)
|
144
144
|
expect(ex.response_status).to eq(499)
|
@@ -149,7 +149,7 @@ RSpec.describe Faraday::Response::RaiseError do
|
|
149
149
|
|
150
150
|
it 'raises Faraday::ServerError for 500 responses' do
|
151
151
|
expect { conn.get('server-error') }.to raise_error(Faraday::ServerError) do |ex|
|
152
|
-
expect(ex.message).to eq('the server responded with status 500')
|
152
|
+
expect(ex.message).to eq('the server responded with status 500 for GET http:/server-error')
|
153
153
|
expect(ex.response[:headers]['X-Error']).to eq('bailout')
|
154
154
|
expect(ex.response[:status]).to eq(500)
|
155
155
|
expect(ex.response_status).to eq(500)
|
data/spec/faraday/utils_spec.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.13.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "@technoweenie"
|
8
8
|
- "@iMacTia"
|
9
9
|
- "@olleolleolle"
|
10
|
-
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: faraday-net_http
|
@@ -60,7 +59,6 @@ dependencies:
|
|
60
59
|
- - ">="
|
61
60
|
- !ruby/object:Gem::Version
|
62
61
|
version: '0'
|
63
|
-
description:
|
64
62
|
email: technoweenie@gmail.com
|
65
63
|
executables: []
|
66
64
|
extensions: []
|
@@ -146,11 +144,10 @@ licenses:
|
|
146
144
|
- MIT
|
147
145
|
metadata:
|
148
146
|
homepage_uri: https://lostisland.github.io/faraday
|
149
|
-
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.
|
147
|
+
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.13.4
|
150
148
|
source_code_uri: https://github.com/lostisland/faraday
|
151
149
|
bug_tracker_uri: https://github.com/lostisland/faraday/issues
|
152
150
|
rubygems_mfa_required: 'true'
|
153
|
-
post_install_message:
|
154
151
|
rdoc_options: []
|
155
152
|
require_paths:
|
156
153
|
- lib
|
@@ -166,8 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
163
|
- !ruby/object:Gem::Version
|
167
164
|
version: '0'
|
168
165
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
170
|
-
signing_key:
|
166
|
+
rubygems_version: 3.6.9
|
171
167
|
specification_version: 4
|
172
168
|
summary: HTTP/REST API client library.
|
173
169
|
test_files: []
|