spaceborne 0.1.25 → 0.1.30
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/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/lib/spaceborne.rb +32 -24
- data/lib/spaceborne/version.rb +1 -1
- data/spaceborne.gemspec +2 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19012125b047e951b20210def0f4ea65b6c7f10542e666eb153df34e02783d34
|
4
|
+
data.tar.gz: dd9e9059c96a19b14baad98b4a86454a41643bb220094c7df62db213017aa99c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 654824c04e0658652b73f32cf59274d63ffc78e44e5f2119b31f367300b70ae76fbce719b8eea06b574acd23de3a4c57571c7bd3d12000a75d713df707784b19
|
7
|
+
data.tar.gz: b9af3be6d62faa09701ca474bb49141e603bff8d00227fcab1c711e8461866cf7bf8c1bb1bd8bbdc56dfb334a54ae158b2cec534b5faf343e84e60462e12fc7e
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.5.5
|
data/lib/spaceborne.rb
CHANGED
@@ -34,12 +34,11 @@ module Spaceborne
|
|
34
34
|
def response_body
|
35
35
|
return '' if response.request.method.casecmp('head').zero?
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
str
|
37
|
+
if json?(response.headers)
|
38
|
+
" JSON_BODY\n#{JSON.pretty_generate(json_body)}\n"
|
39
|
+
else
|
40
|
+
" BODY\n#{response.body}\n"
|
41
|
+
end
|
43
42
|
end
|
44
43
|
|
45
44
|
def request_info(str = "\n")
|
@@ -118,18 +117,23 @@ module Airborne
|
|
118
117
|
end
|
119
118
|
end
|
120
119
|
|
121
|
-
def
|
120
|
+
def pre_request(options)
|
122
121
|
@json_body = nil
|
123
122
|
local_options = split_options(options)
|
124
123
|
handle_proxy(options, local_options)
|
125
124
|
hdrs = calc_headers(options, local_options)
|
126
125
|
@request_body = calc_body(options, local_options)
|
127
|
-
|
126
|
+
[hdrs, @request_body]
|
127
|
+
end
|
128
|
+
|
129
|
+
def make_request(method, url, options = {})
|
130
|
+
hdrs, body = pre_request(options)
|
131
|
+
send_restclient(method, get_url(url), body, hdrs)
|
128
132
|
rescue RestClient::ServerBrokeConnection => e
|
129
133
|
raise e
|
130
134
|
rescue RestClient::Exception => e
|
131
|
-
if [301, 302].include?(e.response
|
132
|
-
e.response
|
135
|
+
if [301, 302].include?(e.response&.code)
|
136
|
+
e.response.&follow_redirection
|
133
137
|
else
|
134
138
|
e.response
|
135
139
|
end
|
@@ -155,16 +159,16 @@ module Airborne
|
|
155
159
|
end
|
156
160
|
end
|
157
161
|
|
158
|
-
def exception_path_adder(
|
162
|
+
def exception_path_adder(args)
|
159
163
|
yield
|
160
164
|
rescue Airborne::ExpectationError => e
|
161
|
-
e.message << "
|
165
|
+
e.message << "\nexpect arguments: #{args}"
|
162
166
|
raise e
|
163
167
|
end
|
164
168
|
|
165
169
|
def expect_json_types(*args)
|
166
170
|
call_with_relative_path(json_body, args) do |param, body|
|
167
|
-
exception_path_adder(args
|
171
|
+
exception_path_adder(args) do
|
168
172
|
expect_json_types_impl(param, body)
|
169
173
|
end
|
170
174
|
end
|
@@ -172,7 +176,7 @@ module Airborne
|
|
172
176
|
|
173
177
|
def expect_json(*args)
|
174
178
|
call_with_relative_path(json_body, args) do |param, body|
|
175
|
-
exception_path_adder(args
|
179
|
+
exception_path_adder(args) do
|
176
180
|
expect_json_impl(param, body)
|
177
181
|
end
|
178
182
|
end
|
@@ -180,7 +184,7 @@ module Airborne
|
|
180
184
|
|
181
185
|
def expect_header_types(*args)
|
182
186
|
call_with_relative_path(response.headers, args) do |param, body|
|
183
|
-
exception_path_adder(args
|
187
|
+
exception_path_adder(args) do
|
184
188
|
expect_json_types_impl(param, body)
|
185
189
|
end
|
186
190
|
end
|
@@ -188,7 +192,7 @@ module Airborne
|
|
188
192
|
|
189
193
|
def expect_header(*args)
|
190
194
|
call_with_relative_path(response.headers, args) do |param, body|
|
191
|
-
exception_path_adder(args
|
195
|
+
exception_path_adder(args) do
|
192
196
|
expect_json_impl(param, body)
|
193
197
|
end
|
194
198
|
end
|
@@ -209,9 +213,9 @@ module Airborne
|
|
209
213
|
when 'Array'
|
210
214
|
expect_all(json, &block)
|
211
215
|
when 'Hash'
|
212
|
-
json.each
|
213
|
-
|
214
|
-
|
216
|
+
json.each { |k, _v| yield json[k] }
|
217
|
+
else
|
218
|
+
raise ExpectationError, "expected array or hash, got #{json.class.name}"
|
215
219
|
end
|
216
220
|
end
|
217
221
|
|
@@ -225,18 +229,22 @@ module Airborne
|
|
225
229
|
end
|
226
230
|
end
|
227
231
|
|
228
|
-
def
|
232
|
+
def iterate_path(path)
|
229
233
|
raise PathError, "Invalid Path, contains '..'" if /\.\./ =~ path
|
230
234
|
|
231
|
-
type = false
|
232
235
|
parts = path.to_s.split('.')
|
233
236
|
parts.each_with_index do |part, index|
|
237
|
+
yield(parts, part, index)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def get_by_path(path, json, type = false, &block)
|
242
|
+
iterate_path(path) do |parts, part, index|
|
234
243
|
if %w[* ?].include?(part)
|
235
244
|
ensure_array_or_hash(path, json)
|
236
245
|
type = part
|
237
|
-
if index < parts.length.pred
|
238
|
-
|
239
|
-
end
|
246
|
+
walk_with_path(type, index, path, parts, json, &block) && return if index < parts.length.pred
|
247
|
+
|
240
248
|
next
|
241
249
|
end
|
242
250
|
json = do_process_json(part, json)
|
data/lib/spaceborne/version.rb
CHANGED
data/spaceborne.gemspec
CHANGED
@@ -12,8 +12,9 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = 'Extends brooklynDev/airborne'
|
13
13
|
spec.homepage = 'https://github.com/keithrw54/spaceborne.git'
|
14
14
|
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '~> 2.5.5'
|
15
16
|
|
16
|
-
spec.files
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
18
|
f.match(%r{^(test|spec|features)/})
|
18
19
|
end
|
19
20
|
spec.bindir = 'exe'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spaceborne
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Williams
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -185,15 +185,15 @@ homepage: https://github.com/keithrw54/spaceborne.git
|
|
185
185
|
licenses:
|
186
186
|
- MIT
|
187
187
|
metadata: {}
|
188
|
-
post_install_message:
|
188
|
+
post_install_message:
|
189
189
|
rdoc_options: []
|
190
190
|
require_paths:
|
191
191
|
- lib
|
192
192
|
required_ruby_version: !ruby/object:Gem::Requirement
|
193
193
|
requirements:
|
194
|
-
- - "
|
194
|
+
- - "~>"
|
195
195
|
- !ruby/object:Gem::Version
|
196
|
-
version:
|
196
|
+
version: 2.5.5
|
197
197
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
199
|
- - ">="
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
version: '0'
|
202
202
|
requirements: []
|
203
203
|
rubygems_version: 3.0.8
|
204
|
-
signing_key:
|
204
|
+
signing_key:
|
205
205
|
specification_version: 4
|
206
206
|
summary: Gem supporting API testing
|
207
207
|
test_files: []
|