f_http_client 0.2.1 → 0.3.0
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/.rubocop.yml +74 -8
- data/CHANGELOG.md +4 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +103 -62
- data/README.md +41 -0
- data/lib/f_http_client/base.rb +2 -1
- data/lib/f_http_client/cache/rails.rb +2 -1
- data/lib/f_http_client/processor/exception.rb +2 -0
- data/lib/f_http_client/processor/response.rb +4 -4
- data/lib/f_http_client/rspec/matchers/f_http_client_response_including.rb +27 -0
- data/lib/f_http_client/rspec/matchers.rb +3 -0
- data/lib/f_http_client/rspec.rb +1 -0
- data/lib/f_http_client/version.rb +1 -1
- data/lib/f_http_client.rb +1 -0
- metadata +7 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bac525ad09c72f1354f9e12325df3954162a0a403a1490954965ebe0857cf1f8
|
|
4
|
+
data.tar.gz: 8dcf73d13e10dac54c0f8160b315c0cfb832b316d7b15f37b1484bfa71e9a173
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc919bb2e2ec31f726a15cb4d811909678daaf76ca63ce0bc2d87d816af9c3cc5f26a4fda77c18909ba0428439fb9e5559c07eecd8bbf7d2354b70ae974edb75
|
|
7
|
+
data.tar.gz: 40452092e5d0a7635c5bbf227750a2d32baf88f0d39eca5a1cd87a1f22af821990568989a8be3438cdbadaa4640dcaac795af4f5402a66136f0c09e5467c41be
|
data/.rubocop.yml
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
plugins:
|
|
2
2
|
- rubocop-rspec
|
|
3
3
|
- rubocop-performance
|
|
4
|
+
- rubocop-vicenzo
|
|
4
5
|
|
|
5
6
|
AllCops:
|
|
6
7
|
TargetRubyVersion: 3.0
|
|
@@ -15,6 +16,14 @@ AllCops:
|
|
|
15
16
|
|
|
16
17
|
##### LAYOUT #####
|
|
17
18
|
|
|
19
|
+
Layout/ArgumentAlignment:
|
|
20
|
+
Enabled: true
|
|
21
|
+
EnforcedStyle: with_fixed_indentation
|
|
22
|
+
|
|
23
|
+
Layout/FirstArgumentIndentation:
|
|
24
|
+
Enabled: true
|
|
25
|
+
EnforcedStyle: consistent
|
|
26
|
+
|
|
18
27
|
Layout/FirstArrayElementIndentation:
|
|
19
28
|
Enabled: true
|
|
20
29
|
EnforcedStyle: consistent
|
|
@@ -23,10 +32,44 @@ Layout/FirstHashElementIndentation:
|
|
|
23
32
|
Enabled: true
|
|
24
33
|
EnforcedStyle: consistent
|
|
25
34
|
|
|
35
|
+
Layout/FirstMethodArgumentLineBreak:
|
|
36
|
+
Enabled: true
|
|
37
|
+
|
|
26
38
|
Layout/LineLength:
|
|
27
39
|
Max: 120
|
|
28
40
|
AllowedPatterns: ['(\A|\s)#']
|
|
29
41
|
|
|
42
|
+
Layout/MultilineMethodArgumentLineBreaks:
|
|
43
|
+
Enabled: true
|
|
44
|
+
|
|
45
|
+
Layout/MultilineMethodCallBraceLayout:
|
|
46
|
+
Enabled: true
|
|
47
|
+
EnforcedStyle: new_line
|
|
48
|
+
|
|
49
|
+
Layout/MultilineMethodCallIndentation:
|
|
50
|
+
Enabled: true
|
|
51
|
+
EnforcedStyle: indented
|
|
52
|
+
|
|
53
|
+
Layout/FirstArrayElementLineBreak:
|
|
54
|
+
Enabled: true
|
|
55
|
+
|
|
56
|
+
Layout/MultilineArrayLineBreaks:
|
|
57
|
+
Enabled: true
|
|
58
|
+
|
|
59
|
+
Layout/MultilineArrayBraceLayout:
|
|
60
|
+
Enabled: true
|
|
61
|
+
EnforcedStyle: new_line
|
|
62
|
+
|
|
63
|
+
Layout/FirstHashElementLineBreak:
|
|
64
|
+
Enabled: true
|
|
65
|
+
|
|
66
|
+
Layout/MultilineHashKeyLineBreaks:
|
|
67
|
+
Enabled: true
|
|
68
|
+
|
|
69
|
+
Layout/MultilineHashBraceLayout:
|
|
70
|
+
Enabled: true
|
|
71
|
+
EnforcedStyle: new_line
|
|
72
|
+
|
|
30
73
|
##### STYLE #####
|
|
31
74
|
|
|
32
75
|
Style/PreferredHashMethods:
|
|
@@ -57,9 +100,6 @@ Style/LambdaCall:
|
|
|
57
100
|
Style/Documentation:
|
|
58
101
|
Enabled: false
|
|
59
102
|
|
|
60
|
-
Style/ClassAndModuleChildren:
|
|
61
|
-
Enabled: false
|
|
62
|
-
|
|
63
103
|
##### LINT #####
|
|
64
104
|
|
|
65
105
|
Lint/MissingSuper:
|
|
@@ -70,7 +110,7 @@ Lint/MissingSuper:
|
|
|
70
110
|
Naming/InclusiveLanguage:
|
|
71
111
|
Enabled: false
|
|
72
112
|
|
|
73
|
-
Naming/
|
|
113
|
+
Naming/PredicatePrefix:
|
|
74
114
|
ForbiddenPrefixes:
|
|
75
115
|
- is_
|
|
76
116
|
- have_
|
|
@@ -110,12 +150,38 @@ RSpec/ContextWording:
|
|
|
110
150
|
RSpec/ExampleLength:
|
|
111
151
|
Max: 20
|
|
112
152
|
|
|
113
|
-
RSpec/
|
|
114
|
-
|
|
115
|
-
|
|
153
|
+
RSpec/MultipleExpectations:
|
|
154
|
+
Exclude:
|
|
155
|
+
- 'spec/f_http_client/rspec/matchers/**/*'
|
|
156
|
+
|
|
157
|
+
# This directory contains specs for custom RSpec matchers.
|
|
158
|
+
# These examples intentionally use nested `expect { ... }.to raise_error(...)`
|
|
159
|
+
# to assert on matcher failure messages, which inherently requires more than
|
|
160
|
+
# one `expect` per example and conflicts with the MultipleExpectations cop.
|
|
161
|
+
#
|
|
162
|
+
# Using `:aggregate_failures` here is not an option, because it captures the
|
|
163
|
+
# inner expectation failure and re-raises an aggregated error, so the outer
|
|
164
|
+
# `raise_error` matcher no longer sees the original `ExpectationNotMetError`
|
|
165
|
+
# and the specs for the failure messages become impossible to express.
|
|
116
166
|
|
|
117
167
|
RSpec/MultipleMemoizedHelpers:
|
|
118
168
|
Enabled: false
|
|
119
169
|
|
|
120
170
|
RSpec/NestedGroups:
|
|
121
171
|
Enabled: false
|
|
172
|
+
|
|
173
|
+
RSpec/SpecFilePathFormat:
|
|
174
|
+
CustomTransform:
|
|
175
|
+
FHTTPClient: f_http_client
|
|
176
|
+
|
|
177
|
+
##### RUBYGEMS #####
|
|
178
|
+
Gemspec/RequireMFA:
|
|
179
|
+
Enabled: false
|
|
180
|
+
|
|
181
|
+
##### Vicenzo #####
|
|
182
|
+
|
|
183
|
+
Vicenzo/Style/MultilineMethodCallParentheses:
|
|
184
|
+
AllowedMethods:
|
|
185
|
+
- to
|
|
186
|
+
- not_to
|
|
187
|
+
- to_not
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
- Add `f_http_client_response_including` RSpec matcher for testing HTTParty::Response objects with nested matchers
|
|
4
|
+
- Fix Ruby 4.0+ compatibility by adding activesupport >= 7.2, ostruct, and csv dependencies
|
|
5
|
+
- Change Disable rubygems MFA checking #14
|
|
6
|
+
|
|
3
7
|
## [0.2.1] - 2023-09-27
|
|
4
8
|
|
|
5
9
|
- Add rescue to SocketError exception. #12
|
data/Gemfile
CHANGED
|
@@ -6,12 +6,17 @@ source 'https://rubygems.org'
|
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
8
|
group :development do
|
|
9
|
+
gem 'benchmark' # Required by rubocop on Ruby 4+
|
|
10
|
+
gem 'racc' # Required by parser on Ruby 4+
|
|
9
11
|
gem 'rubocop'
|
|
10
12
|
gem 'rubocop-performance'
|
|
11
13
|
gem 'rubocop-rspec'
|
|
14
|
+
gem 'rubocop-vicenzo'
|
|
12
15
|
end
|
|
13
16
|
|
|
14
17
|
group :test do
|
|
18
|
+
gem 'csv' # Required by httparty on Ruby 4+ (moved from stdlib)
|
|
19
|
+
gem 'ostruct' # Required by simplecov on Ruby 4+ (moved from stdlib)
|
|
15
20
|
gem 'rspec', '~> 3.0'
|
|
16
21
|
gem 'simplecov'
|
|
17
22
|
gem 'webmock'
|
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
f_http_client (0.
|
|
5
|
-
activesupport
|
|
4
|
+
f_http_client (0.3.0)
|
|
5
|
+
activesupport (>= 7.2)
|
|
6
6
|
addressable
|
|
7
7
|
dry-configurable
|
|
8
8
|
dry-initializer
|
|
@@ -12,113 +12,154 @@ PATH
|
|
|
12
12
|
GEM
|
|
13
13
|
remote: https://rubygems.org/
|
|
14
14
|
specs:
|
|
15
|
-
activesupport (
|
|
16
|
-
|
|
15
|
+
activesupport (8.1.2)
|
|
16
|
+
base64
|
|
17
|
+
bigdecimal
|
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
19
|
+
connection_pool (>= 2.2.5)
|
|
20
|
+
drb
|
|
17
21
|
i18n (>= 1.6, < 2)
|
|
22
|
+
json
|
|
23
|
+
logger (>= 1.4.2)
|
|
18
24
|
minitest (>= 5.1)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
securerandom (>= 0.3)
|
|
26
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
27
|
+
uri (>= 0.13.1)
|
|
28
|
+
addressable (2.8.8)
|
|
29
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
30
|
+
ast (2.4.3)
|
|
31
|
+
base64 (0.3.0)
|
|
32
|
+
benchmark (0.5.0)
|
|
33
|
+
bigdecimal (4.0.1)
|
|
23
34
|
coderay (1.1.3)
|
|
24
|
-
concurrent-ruby (1.
|
|
25
|
-
|
|
35
|
+
concurrent-ruby (1.3.6)
|
|
36
|
+
connection_pool (3.0.2)
|
|
37
|
+
crack (1.0.1)
|
|
38
|
+
bigdecimal
|
|
26
39
|
rexml
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
csv (3.3.5)
|
|
41
|
+
diff-lcs (1.6.2)
|
|
42
|
+
docile (1.4.1)
|
|
43
|
+
drb (2.2.3)
|
|
44
|
+
dry-configurable (1.3.0)
|
|
45
|
+
dry-core (~> 1.1)
|
|
31
46
|
zeitwerk (~> 2.6)
|
|
32
|
-
dry-core (1.0
|
|
47
|
+
dry-core (1.2.0)
|
|
33
48
|
concurrent-ruby (~> 1.0)
|
|
49
|
+
logger
|
|
34
50
|
zeitwerk (~> 2.6)
|
|
35
|
-
dry-initializer (3.
|
|
36
|
-
f_service (0.3.
|
|
37
|
-
hashdiff (1.
|
|
38
|
-
httparty (0.
|
|
51
|
+
dry-initializer (3.2.0)
|
|
52
|
+
f_service (0.3.1)
|
|
53
|
+
hashdiff (1.2.1)
|
|
54
|
+
httparty (0.24.2)
|
|
55
|
+
csv
|
|
39
56
|
mini_mime (>= 1.0.0)
|
|
40
57
|
multi_xml (>= 0.5.2)
|
|
41
|
-
i18n (1.14.
|
|
58
|
+
i18n (1.14.8)
|
|
42
59
|
concurrent-ruby (~> 1.0)
|
|
43
|
-
json (2.
|
|
44
|
-
|
|
60
|
+
json (2.18.0)
|
|
61
|
+
language_server-protocol (3.17.0.5)
|
|
62
|
+
lint_roller (1.1.0)
|
|
63
|
+
logger (1.7.0)
|
|
64
|
+
method_source (1.1.0)
|
|
45
65
|
mini_mime (1.1.5)
|
|
46
|
-
minitest (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
66
|
+
minitest (6.0.1)
|
|
67
|
+
prism (~> 1.5)
|
|
68
|
+
multi_xml (0.8.1)
|
|
69
|
+
bigdecimal (>= 3.1, < 5)
|
|
70
|
+
ostruct (0.6.3)
|
|
71
|
+
parallel (1.27.0)
|
|
72
|
+
parser (3.3.10.1)
|
|
50
73
|
ast (~> 2.4.1)
|
|
74
|
+
racc
|
|
75
|
+
prism (1.9.0)
|
|
51
76
|
pry (0.14.2)
|
|
52
77
|
coderay (~> 1.1)
|
|
53
78
|
method_source (~> 1.0)
|
|
54
79
|
pry-nav (1.0.0)
|
|
55
80
|
pry (>= 0.9.10, < 0.15)
|
|
56
|
-
public_suffix (
|
|
81
|
+
public_suffix (7.0.2)
|
|
82
|
+
racc (1.8.1)
|
|
57
83
|
rainbow (3.1.1)
|
|
58
|
-
rake (13.
|
|
59
|
-
regexp_parser (2.
|
|
60
|
-
rexml (3.
|
|
61
|
-
rspec (3.
|
|
62
|
-
rspec-core (~> 3.
|
|
63
|
-
rspec-expectations (~> 3.
|
|
64
|
-
rspec-mocks (~> 3.
|
|
65
|
-
rspec-core (3.
|
|
66
|
-
rspec-support (~> 3.
|
|
67
|
-
rspec-expectations (3.
|
|
84
|
+
rake (13.3.1)
|
|
85
|
+
regexp_parser (2.11.3)
|
|
86
|
+
rexml (3.4.4)
|
|
87
|
+
rspec (3.13.2)
|
|
88
|
+
rspec-core (~> 3.13.0)
|
|
89
|
+
rspec-expectations (~> 3.13.0)
|
|
90
|
+
rspec-mocks (~> 3.13.0)
|
|
91
|
+
rspec-core (3.13.6)
|
|
92
|
+
rspec-support (~> 3.13.0)
|
|
93
|
+
rspec-expectations (3.13.5)
|
|
68
94
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
69
|
-
rspec-support (~> 3.
|
|
70
|
-
rspec-mocks (3.
|
|
95
|
+
rspec-support (~> 3.13.0)
|
|
96
|
+
rspec-mocks (3.13.7)
|
|
71
97
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
72
|
-
rspec-support (~> 3.
|
|
73
|
-
rspec-support (3.
|
|
74
|
-
rubocop (1.
|
|
98
|
+
rspec-support (~> 3.13.0)
|
|
99
|
+
rspec-support (3.13.7)
|
|
100
|
+
rubocop (1.84.0)
|
|
75
101
|
json (~> 2.3)
|
|
102
|
+
language_server-protocol (~> 3.17.0.2)
|
|
103
|
+
lint_roller (~> 1.1.0)
|
|
76
104
|
parallel (~> 1.10)
|
|
77
|
-
parser (>= 3.
|
|
105
|
+
parser (>= 3.3.0.2)
|
|
78
106
|
rainbow (>= 2.2.2, < 4.0)
|
|
79
|
-
regexp_parser (>=
|
|
80
|
-
|
|
81
|
-
rubocop-ast (>= 1.24.1, < 2.0)
|
|
107
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
108
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
82
109
|
ruby-progressbar (~> 1.7)
|
|
83
|
-
unicode-display_width (>= 2.4.0, <
|
|
84
|
-
rubocop-ast (1.
|
|
85
|
-
parser (>= 3.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
rubocop (>= 1.
|
|
90
|
-
rubocop-ast (>=
|
|
91
|
-
rubocop-rspec (
|
|
92
|
-
|
|
93
|
-
rubocop
|
|
94
|
-
|
|
110
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
111
|
+
rubocop-ast (1.49.0)
|
|
112
|
+
parser (>= 3.3.7.2)
|
|
113
|
+
prism (~> 1.7)
|
|
114
|
+
rubocop-performance (1.26.1)
|
|
115
|
+
lint_roller (~> 1.1)
|
|
116
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
117
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
118
|
+
rubocop-rspec (3.9.0)
|
|
119
|
+
lint_roller (~> 1.1)
|
|
120
|
+
rubocop (~> 1.81)
|
|
121
|
+
rubocop-vicenzo (0.3.0)
|
|
122
|
+
lint_roller (~> 1.1)
|
|
123
|
+
rubocop (>= 1.72.2)
|
|
124
|
+
rubocop-rspec (>= 3.5.0)
|
|
125
|
+
ruby-progressbar (1.13.0)
|
|
126
|
+
securerandom (0.4.1)
|
|
95
127
|
simplecov (0.22.0)
|
|
96
128
|
docile (~> 1.1)
|
|
97
129
|
simplecov-html (~> 0.11)
|
|
98
130
|
simplecov_json_formatter (~> 0.1)
|
|
99
|
-
simplecov-html (0.
|
|
131
|
+
simplecov-html (0.13.2)
|
|
100
132
|
simplecov_json_formatter (0.1.4)
|
|
101
133
|
tzinfo (2.0.6)
|
|
102
134
|
concurrent-ruby (~> 1.0)
|
|
103
|
-
unicode-display_width (2.
|
|
104
|
-
|
|
135
|
+
unicode-display_width (3.2.0)
|
|
136
|
+
unicode-emoji (~> 4.1)
|
|
137
|
+
unicode-emoji (4.2.0)
|
|
138
|
+
uri (1.1.1)
|
|
139
|
+
webmock (3.26.1)
|
|
105
140
|
addressable (>= 2.8.0)
|
|
106
141
|
crack (>= 0.3.2)
|
|
107
142
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
108
|
-
zeitwerk (2.
|
|
143
|
+
zeitwerk (2.7.4)
|
|
109
144
|
|
|
110
145
|
PLATFORMS
|
|
146
|
+
x86_64-darwin-24
|
|
111
147
|
x86_64-linux
|
|
112
148
|
|
|
113
149
|
DEPENDENCIES
|
|
150
|
+
benchmark
|
|
151
|
+
csv
|
|
114
152
|
f_http_client!
|
|
153
|
+
ostruct
|
|
115
154
|
pry
|
|
116
155
|
pry-nav
|
|
156
|
+
racc
|
|
117
157
|
rake (~> 13.0)
|
|
118
158
|
rspec (~> 3.0)
|
|
119
159
|
rubocop
|
|
120
160
|
rubocop-performance
|
|
121
161
|
rubocop-rspec
|
|
162
|
+
rubocop-vicenzo
|
|
122
163
|
simplecov
|
|
123
164
|
webmock
|
|
124
165
|
|
data/README.md
CHANGED
|
@@ -109,6 +109,47 @@ The class *FHTTPClient::Base* provides the following options to help building th
|
|
|
109
109
|
- *options*: can be used provide any other option for HTTParty;
|
|
110
110
|
- *path_params*, can be used to fills params which is in the request path.
|
|
111
111
|
|
|
112
|
+
## RSpec Matchers
|
|
113
|
+
|
|
114
|
+
### `f_http_client_response_including`
|
|
115
|
+
|
|
116
|
+
Tests HTTParty::Response objects with support for nested RSpec matchers.
|
|
117
|
+
|
|
118
|
+
```rb
|
|
119
|
+
require 'f_http_client/rspec'
|
|
120
|
+
|
|
121
|
+
RSpec.describe MyApi::Products::List do
|
|
122
|
+
it 'returns successful response with products' do
|
|
123
|
+
stub_request(:get, "https://api.example.com/products")
|
|
124
|
+
.to_return(status: 200, body: { products: [{id: 1}, {id: 2}] }.to_json)
|
|
125
|
+
|
|
126
|
+
service_result = described_class.()
|
|
127
|
+
|
|
128
|
+
# Use with FService matchers
|
|
129
|
+
expect(service_result)
|
|
130
|
+
.to have_succeed_with(:ok, :successful)
|
|
131
|
+
.and_value(f_http_client_response_including(products: have_attributes(size: 2), page: be_a(Integer)))
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'supports nested matchers' do
|
|
135
|
+
stub_request(:get, "https://api.example.com/products")
|
|
136
|
+
.to_return(status: 200, body: { items: [{id: 1}] }.to_json)
|
|
137
|
+
|
|
138
|
+
response = described_class.().value
|
|
139
|
+
|
|
140
|
+
# Direct response testing
|
|
141
|
+
expect(response)
|
|
142
|
+
.to f_http_client_response_including(items: a_collection_containing_exactly(a_hash_including(id: 1)))
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The matcher:
|
|
148
|
+
- Automatically calls `parsed_response` on HTTParty::Response objects
|
|
149
|
+
- Supports any nested RSpec matchers (`have_attributes`, `a_hash_including`, `be_a`, etc.)
|
|
150
|
+
- Works seamlessly with FService's `.and_value()` and `.and_error()` matchers
|
|
151
|
+
- Provides clear failure messages showing expected vs actual
|
|
152
|
+
|
|
112
153
|
## Development
|
|
113
154
|
|
|
114
155
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
|
data/lib/f_http_client/base.rb
CHANGED
|
@@ -23,7 +23,8 @@ module FHTTPClient
|
|
|
23
23
|
FHTTPClient::Processor::Response.(response: response, log_strategy: log_strategy)
|
|
24
24
|
end
|
|
25
25
|
rescue StandardError => e
|
|
26
|
-
FHTTPClient::Processor::Exception
|
|
26
|
+
FHTTPClient::Processor::Exception
|
|
27
|
+
.(error: e, log_strategy: log_strategy)
|
|
27
28
|
.on_failure(:uncaught_error) { raise e }
|
|
28
29
|
end
|
|
29
30
|
|
|
@@ -81,10 +81,10 @@ module FHTTPClient
|
|
|
81
81
|
# # => "Unprocessable Entity"
|
|
82
82
|
def message
|
|
83
83
|
@message ||= response_class
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
.to_s
|
|
85
|
+
.delete_prefix('Net::HTTP')
|
|
86
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1 \2')
|
|
87
|
+
.gsub(/([a-z])([A-Z])/, '\1 \2')
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
# Private
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec::Matchers.define :f_http_client_response_including do |expected_hash|
|
|
4
|
+
match do |actual|
|
|
5
|
+
return false unless actual.respond_to?(:parsed_response)
|
|
6
|
+
|
|
7
|
+
@actual_parsed = actual.parsed_response
|
|
8
|
+
|
|
9
|
+
# Check if all expected key-value pairs are present in actual
|
|
10
|
+
expected_hash.all? do |expected_key, expected_value|
|
|
11
|
+
actual_value = @actual_parsed[expected_key]
|
|
12
|
+
# Use values_match? to support nested matchers
|
|
13
|
+
values_match?(expected_value, actual_value)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
failure_message do |actual|
|
|
18
|
+
if actual.respond_to?(:parsed_response)
|
|
19
|
+
"expected HTTParty::Response parsed_response to include #{expected_hash.inspect}, " \
|
|
20
|
+
"but got #{@actual_parsed.inspect}"
|
|
21
|
+
else
|
|
22
|
+
"expected an HTTParty::Response, but got #{actual.class}"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
diffable
|
|
27
|
+
end
|
data/lib/f_http_client/rspec.rb
CHANGED
data/lib/f_http_client.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require_relative 'f_http_client/version'
|
|
4
4
|
require 'active_support/core_ext/array'
|
|
5
5
|
require 'active_support/core_ext/enumerable'
|
|
6
|
+
require 'active_support/core_ext/object/blank'
|
|
6
7
|
require 'active_support/core_ext/string'
|
|
7
8
|
require 'addressable'
|
|
8
9
|
require 'dry-configurable'
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: f_http_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fretadao Tech Team
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activesupport
|
|
@@ -16,14 +15,14 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
18
|
+
version: '7.2'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
25
|
+
version: '7.2'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: addressable
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -94,7 +93,6 @@ dependencies:
|
|
|
94
93
|
- - ">="
|
|
95
94
|
- !ruby/object:Gem::Version
|
|
96
95
|
version: '0'
|
|
97
|
-
description:
|
|
98
96
|
email:
|
|
99
97
|
- tech@fretadao.com.br
|
|
100
98
|
executables: []
|
|
@@ -125,6 +123,8 @@ files:
|
|
|
125
123
|
- lib/f_http_client/processor/exception.rb
|
|
126
124
|
- lib/f_http_client/processor/response.rb
|
|
127
125
|
- lib/f_http_client/rspec.rb
|
|
126
|
+
- lib/f_http_client/rspec/matchers.rb
|
|
127
|
+
- lib/f_http_client/rspec/matchers/f_http_client_response_including.rb
|
|
128
128
|
- lib/f_http_client/rspec/support.rb
|
|
129
129
|
- lib/f_http_client/rspec/support/helpers.rb
|
|
130
130
|
- lib/f_http_client/rspec/support/helpers/fake_response.rb
|
|
@@ -141,7 +141,6 @@ metadata:
|
|
|
141
141
|
source_code_uri: https://github.com/Fretadao/f_http_client
|
|
142
142
|
changelog_uri: https://github.com/Fretadao/f_http_client/blob/master/CHANGELOG.md
|
|
143
143
|
rubygems_mfa_required: 'false'
|
|
144
|
-
post_install_message:
|
|
145
144
|
rdoc_options: []
|
|
146
145
|
require_paths:
|
|
147
146
|
- lib
|
|
@@ -156,8 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
156
155
|
- !ruby/object:Gem::Version
|
|
157
156
|
version: '0'
|
|
158
157
|
requirements: []
|
|
159
|
-
rubygems_version:
|
|
160
|
-
signing_key:
|
|
158
|
+
rubygems_version: 4.0.3
|
|
161
159
|
specification_version: 4
|
|
162
160
|
summary: Gem to provade a base for an HTTP client using FService architecture
|
|
163
161
|
test_files: []
|