faraday 2.7.5 → 2.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/Rakefile +3 -1
- data/lib/faraday/error.rb +9 -3
- data/lib/faraday/options.rb +1 -0
- data/lib/faraday/request/instrumentation.rb +2 -0
- data/lib/faraday/request.rb +2 -0
- data/lib/faraday/version.rb +1 -1
- data/spec/faraday/error_spec.rb +31 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 577d9d7b4585ac946a788742a72828cb20a627e843754a195a12c9b60df7fcf1
|
4
|
+
data.tar.gz: 4f87ff29ceda48a5f5f3bf14ea07a8b04bb0bdc521cec478ec570fc7beaf8ef9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2585b9b639bcb64bb963264224c88c1716e890c485e9ac9c356d1f6f8547ed67718c78ee26e88ea93392757686c30f5cc1f17a75f645959bfde0aeffae4a346
|
7
|
+
data.tar.gz: d036376b82bf8bd6459220c06fe8151a374f5914d6b16fd2633c62620dcde1f15911abffa250859269139b7aec035de2a0953f661a8fc50cfe7ba55b2f93928c
|
data/README.md
CHANGED
@@ -12,7 +12,8 @@ requests. Instead, you probably want to have a look at [Awesome Faraday][awesome
|
|
12
12
|
## Getting Started
|
13
13
|
|
14
14
|
The best starting point is the [Faraday Website][website], with its introduction and explanation.
|
15
|
-
|
15
|
+
|
16
|
+
Need more details? See the [Faraday API Documentation][apidoc] to see how it works internally, or take a look at [Advanced techniques for calling HTTP APIs in Ruby](https://mattbrictson.com/blog/advanced-http-techniques-in-ruby) blog post from @mattbrictson 🚀
|
16
17
|
|
17
18
|
## Supported Ruby versions
|
18
19
|
|
data/Rakefile
CHANGED
data/lib/faraday/error.rb
CHANGED
@@ -29,15 +29,21 @@ module Faraday
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def response_status
|
32
|
-
|
32
|
+
return unless @response
|
33
|
+
|
34
|
+
@response.is_a?(Faraday::Response) ? @response.status : @response[:status]
|
33
35
|
end
|
34
36
|
|
35
37
|
def response_headers
|
36
|
-
|
38
|
+
return unless @response
|
39
|
+
|
40
|
+
@response.is_a?(Faraday::Response) ? @response.headers : @response[:headers]
|
37
41
|
end
|
38
42
|
|
39
43
|
def response_body
|
40
|
-
|
44
|
+
return unless @response
|
45
|
+
|
46
|
+
@response.is_a?(Faraday::Response) ? @response.body : @response[:body]
|
41
47
|
end
|
42
48
|
|
43
49
|
protected
|
data/lib/faraday/options.rb
CHANGED
@@ -6,11 +6,13 @@ module Faraday
|
|
6
6
|
class Instrumentation < Faraday::Middleware
|
7
7
|
# Options class used in Request::Instrumentation class.
|
8
8
|
Options = Faraday::Options.new(:name, :instrumenter) do
|
9
|
+
remove_method :name
|
9
10
|
# @return [String]
|
10
11
|
def name
|
11
12
|
self[:name] ||= 'request.faraday'
|
12
13
|
end
|
13
14
|
|
15
|
+
remove_method :instrumenter
|
14
16
|
# @return [Class]
|
15
17
|
def instrumenter
|
16
18
|
self[:instrumenter] ||= ActiveSupport::Notifications
|
data/lib/faraday/request.rb
CHANGED
@@ -42,6 +42,7 @@ module Faraday
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
remove_method :params=
|
45
46
|
# Replace params, preserving the existing hash type.
|
46
47
|
#
|
47
48
|
# @param hash [Hash] new params
|
@@ -53,6 +54,7 @@ module Faraday
|
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
57
|
+
remove_method :headers=
|
56
58
|
# Replace request headers, preserving the existing hash type.
|
57
59
|
#
|
58
60
|
# @param hash [Hash] new headers
|
data/lib/faraday/version.rb
CHANGED
data/spec/faraday/error_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe Faraday::
|
3
|
+
RSpec.describe Faraday::Error do
|
4
4
|
describe '.initialize' do
|
5
5
|
subject { described_class.new(exception, response) }
|
6
6
|
let(:response) { nil }
|
@@ -12,8 +12,10 @@ RSpec.describe Faraday::ClientError do
|
|
12
12
|
it { expect(subject.response).to be_nil }
|
13
13
|
it { expect(subject.message).to eq(exception.message) }
|
14
14
|
it { expect(subject.backtrace).to eq(exception.backtrace) }
|
15
|
-
it { expect(subject.inspect).to eq('#<Faraday::
|
15
|
+
it { expect(subject.inspect).to eq('#<Faraday::Error wrapped=#<RuntimeError: test>>') }
|
16
16
|
it { expect(subject.response_status).to be_nil }
|
17
|
+
it { expect(subject.response_headers).to be_nil }
|
18
|
+
it { expect(subject.response_body).to be_nil }
|
17
19
|
end
|
18
20
|
|
19
21
|
context 'with response hash' do
|
@@ -22,8 +24,10 @@ RSpec.describe Faraday::ClientError do
|
|
22
24
|
it { expect(subject.wrapped_exception).to be_nil }
|
23
25
|
it { expect(subject.response).to eq(exception) }
|
24
26
|
it { expect(subject.message).to eq('the server responded with status 400') }
|
25
|
-
it { expect(subject.inspect).to eq('#<Faraday::
|
27
|
+
it { expect(subject.inspect).to eq('#<Faraday::Error response={:status=>400}>') }
|
26
28
|
it { expect(subject.response_status).to eq(400) }
|
29
|
+
it { expect(subject.response_headers).to be_nil }
|
30
|
+
it { expect(subject.response_body).to be_nil }
|
27
31
|
end
|
28
32
|
|
29
33
|
context 'with string' do
|
@@ -32,8 +36,10 @@ RSpec.describe Faraday::ClientError do
|
|
32
36
|
it { expect(subject.wrapped_exception).to be_nil }
|
33
37
|
it { expect(subject.response).to be_nil }
|
34
38
|
it { expect(subject.message).to eq('custom message') }
|
35
|
-
it { expect(subject.inspect).to eq('#<Faraday::
|
39
|
+
it { expect(subject.inspect).to eq('#<Faraday::Error #<Faraday::Error: custom message>>') }
|
36
40
|
it { expect(subject.response_status).to be_nil }
|
41
|
+
it { expect(subject.response_headers).to be_nil }
|
42
|
+
it { expect(subject.response_body).to be_nil }
|
37
43
|
end
|
38
44
|
|
39
45
|
context 'with anything else #to_s' do
|
@@ -42,8 +48,10 @@ RSpec.describe Faraday::ClientError do
|
|
42
48
|
it { expect(subject.wrapped_exception).to be_nil }
|
43
49
|
it { expect(subject.response).to be_nil }
|
44
50
|
it { expect(subject.message).to eq('["error1", "error2"]') }
|
45
|
-
it { expect(subject.inspect).to eq('#<Faraday::
|
51
|
+
it { expect(subject.inspect).to eq('#<Faraday::Error #<Faraday::Error: ["error1", "error2"]>>') }
|
46
52
|
it { expect(subject.response_status).to be_nil }
|
53
|
+
it { expect(subject.response_headers).to be_nil }
|
54
|
+
it { expect(subject.response_body).to be_nil }
|
47
55
|
end
|
48
56
|
|
49
57
|
context 'with exception string and response hash' do
|
@@ -53,8 +61,25 @@ RSpec.describe Faraday::ClientError do
|
|
53
61
|
it { expect(subject.wrapped_exception).to be_nil }
|
54
62
|
it { expect(subject.response).to eq(response) }
|
55
63
|
it { expect(subject.message).to eq('custom message') }
|
56
|
-
it { expect(subject.inspect).to eq('#<Faraday::
|
64
|
+
it { expect(subject.inspect).to eq('#<Faraday::Error response={:status=>400}>') }
|
57
65
|
it { expect(subject.response_status).to eq(400) }
|
66
|
+
it { expect(subject.response_headers).to be_nil }
|
67
|
+
it { expect(subject.response_body).to be_nil }
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'with exception and response object' do
|
71
|
+
let(:exception) { RuntimeError.new('test') }
|
72
|
+
let(:body) { { test: 'test' } }
|
73
|
+
let(:headers) { { 'Content-Type' => 'application/json' } }
|
74
|
+
let(:response) { Faraday::Response.new(status: 400, response_headers: headers, response_body: body) }
|
75
|
+
|
76
|
+
it { expect(subject.wrapped_exception).to eq(exception) }
|
77
|
+
it { expect(subject.response).to eq(response) }
|
78
|
+
it { expect(subject.message).to eq(exception.message) }
|
79
|
+
it { expect(subject.backtrace).to eq(exception.backtrace) }
|
80
|
+
it { expect(subject.response_status).to eq(400) }
|
81
|
+
it { expect(subject.response_headers).to eq(headers) }
|
82
|
+
it { expect(subject.response_body).to eq(body) }
|
58
83
|
end
|
59
84
|
end
|
60
85
|
end
|
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: 2.7.
|
4
|
+
version: 2.7.7
|
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: 2023-
|
13
|
+
date: 2023-06-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday-net_http
|
@@ -131,7 +131,7 @@ licenses:
|
|
131
131
|
- MIT
|
132
132
|
metadata:
|
133
133
|
homepage_uri: https://lostisland.github.io/faraday
|
134
|
-
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.7.
|
134
|
+
changelog_uri: https://github.com/lostisland/faraday/releases/tag/v2.7.7
|
135
135
|
source_code_uri: https://github.com/lostisland/faraday
|
136
136
|
bug_tracker_uri: https://github.com/lostisland/faraday/issues
|
137
137
|
post_install_message:
|