spaceborne 0.1.40 → 0.1.44

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c11204f7139c5e5507dfae5c022cfbacaa4f09d9311b85c3e32824497b5e0828
4
- data.tar.gz: 785da01072d57bb89c32fc9c021c42a0b188c1f2a188843b5c86e011a1bbac69
3
+ metadata.gz: 4c1ee4d4fbb158b69d6f3edccf132cbdf29dfb3a32f1fc8c0289bd4c784762df
4
+ data.tar.gz: f0019dce79d257d48048bf04e6ead4fa77abf6e7fcd7c693146ea537808ed429
5
5
  SHA512:
6
- metadata.gz: '090ba089dd166f14cd0dc259fc9887982493e4e433beafd12bb0e645e6fa2deaaade5d183868463e5325ab926508dd799e42bed866cc337004a0f196f2a8b87e'
7
- data.tar.gz: a537d9b3bc27c998931ed409481f39cea26c2efcda803d5556848dc8f8fcca8559628ef03223b02db214cc17970794c3f6f6c0469187af91933f4ccdffc7f7a1
6
+ metadata.gz: dd162f7c0af43b8b1f7bc86e88c52313b315d735b6f4d00f3f95e0c9cf7c2bed20afc1908651e3a62225bf67c977e0942a0bb5f37fff082a156886e19b434483
7
+ data.tar.gz: f4742ef12f777f15a7680c4ab83e6d7cec44c909f1f7f5eb254e05e7ab252ef6d63bc9ffbda4a93cced6225bda1f66abe3b3d00c8d89fa2d4d204bb7f0deb454
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.5.5
1
+ ruby-2.6.3
@@ -1,3 +1,3 @@
1
1
  module Spaceborne
2
- VERSION = '0.1.40'.freeze
2
+ VERSION = '0.1.44'.freeze
3
3
  end
data/lib/spaceborne.rb CHANGED
@@ -186,7 +186,9 @@ module Airborne
186
186
 
187
187
  def exception_path_adder(args, body)
188
188
  yield
189
- rescue RSpec::Expectations::ExpectationNotMetError, Airborne::ExpectationError => e
189
+ rescue RSpec::Expectations::ExpectationNotMetError,
190
+ ExpectationError,
191
+ Airborne::ExpectationError => e
190
192
  e.message << "\nexpect arguments: #{args}\ndata element: #{body}"
191
193
  raise e
192
194
  end
@@ -227,28 +229,28 @@ module Airborne
227
229
  if data.is_a?(Hash)
228
230
  OptionalHashTypeExpectations.new(data)
229
231
  else
230
- OptionalPathExpectations.new(data)
232
+ Airborne::OptionalPathExpectations.new(data)
231
233
  end
232
234
  end
233
235
  end
234
236
 
235
237
  # extension to handle hash value checking
236
238
  module PathMatcher
237
- def handle_container(json, &block)
239
+ def handle_container(path, json, &block)
238
240
  case json.class.name
239
241
  when 'Array'
240
242
  expect_all(json, &block)
241
243
  when 'Hash'
242
244
  json.each { |k, _v| yield json[k] }
243
245
  else
244
- raise ExpectationError, "expected array or hash, got #{json.class.name}"
246
+ raise ExpectationError, "expected array or hash at #{path}, got #{json.class.name}"
245
247
  end
246
248
  end
247
249
 
248
250
  def handle_type(type, path, json, &block)
249
251
  case type.to_s
250
252
  when '*'
251
- handle_container(json, &block)
253
+ handle_container(path, json, &block)
252
254
  when '?'
253
255
  expect_one(path, json, &block)
254
256
  else
@@ -301,14 +303,20 @@ module Airborne
301
303
  ' from JSON response'
302
304
  end
303
305
 
306
+ def handle_missing_errors(type, path, sub_path, element, &block)
307
+ exception_path_adder({ type: type, path: sub_path }, element) do
308
+ get_by_path(make_sub_path_optional(path, sub_path), element, &block)
309
+ end
310
+ end
311
+
304
312
  def walk_with_path(type, index, path, parts, json, &block)
305
313
  last_error = nil
306
314
  item_count = json.length
307
315
  error_count = 0
308
316
  json.each do |element|
317
+ sub_path = parts[(index.next)...(parts.length)].join('.')
309
318
  begin
310
- sub_path = parts[(index.next)...(parts.length)].join('.')
311
- get_by_path(make_sub_path_optional(path, sub_path), element, &block)
319
+ handle_missing_errors(type, path, sub_path, element, &block)
312
320
  rescue Exception => e
313
321
  last_error = e
314
322
  error_count += 1
data/spaceborne.gemspec CHANGED
@@ -12,7 +12,7 @@ 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
+ spec.required_ruby_version = '~> 2.6'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
18
  f.match(%r{^(test|spec|features)/})
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.40
4
+ version: 0.1.44
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Williams
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-23 00:00:00.000000000 Z
11
+ date: 2021-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -193,14 +193,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
193
  requirements:
194
194
  - - "~>"
195
195
  - !ruby/object:Gem::Version
196
- version: 2.5.5
196
+ version: '2.6'
197
197
  required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - ">="
200
200
  - !ruby/object:Gem::Version
201
201
  version: '0'
202
202
  requirements: []
203
- rubygems_version: 3.0.9
203
+ rubygems_version: 3.0.8
204
204
  signing_key:
205
205
  specification_version: 4
206
206
  summary: Gem supporting API testing