airborne 0.2.10 → 0.2.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76d1f2d5892782be324dedfac91cce34f4afe075
4
- data.tar.gz: 30a16b7055de4ac3662454d05caacf645640cb0b
3
+ metadata.gz: 9a17018ee960799abaabe77e8e53cd7933b1c256
4
+ data.tar.gz: 5ffee8561f16813ed64b2d58feabc054a0c7e27a
5
5
  SHA512:
6
- metadata.gz: 530db301f9293ce05f59531e758d1f5da77a53e584f041d391c99866c917c192a188773b81dfc9505240ab03539eea51292e90a12445e760af48d4ac588ee3db
7
- data.tar.gz: 96d100dfeb6c6a5086a1787acbfba797281d81d6b2b68bce4fea8a2665ed466b4e464a665d8f83ca779a1f813abcb44fb5afff8e8781f18495c90a4a1605c05d
6
+ metadata.gz: 391e4cc6d0a84acbd86b88aeece81812a29e6beb045512973d2b7fb7d65dcbc8cd2a79ce338252e9a4ea91e3214d7ef5fd93d4c2fb88cfea92076e97cbd1f196
7
+ data.tar.gz: 37babe87aaa640f11b246b8b7177baa2e230a1fc1189d6d6bb447a6ba49b6396be9ebd50c46c0befbdce51dc3253d452833467d6caa7886f260fdc1abc5a8c2f
data/airborne.gemspec CHANGED
@@ -2,11 +2,11 @@ require 'date'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'airborne'
5
- s.version = '0.2.10'
5
+ s.version = '0.2.11'
6
6
  s.date = Date.today.to_s
7
7
  s.summary = 'RSpec driven API testing framework'
8
8
  s.authors = ['Alex Friedman', 'Seth Pollack']
9
- s.email = ['a.friedman07@gmail.com', 'teampollack@gmail.com']
9
+ s.email = ['a.friedman07@gmail.com', 'seth@sethpollack.net']
10
10
  s.require_paths = ['lib']
11
11
  s.files = `git ls-files`.split("\n")
12
12
  s.license = 'MIT'
@@ -103,7 +103,7 @@ module Airborne
103
103
 
104
104
  actual = convert_to_date(actual) if expected == :date
105
105
 
106
- return expect_type(expected, actual.class) if expected.is_a?(Symbol)
106
+ return expect_type(expected, actual) if expected.is_a?(Symbol)
107
107
  return expected.call(actual) if expected.is_a?(Proc)
108
108
 
109
109
  keys = []
@@ -120,14 +120,12 @@ module Airborne
120
120
  next expect_json_types_impl(type, value) if hash?(type)
121
121
  next type.call(value) if type.is_a?(Proc)
122
122
 
123
- val_class = value.class
124
-
125
123
  type_string = type.to_s
126
124
 
127
125
  if type_string.include?('array_of') && !(type_string.include?('or_null') && value.nil?)
128
- check_array_types(value, val_class, prop, type)
126
+ check_array_types(value, prop, type)
129
127
  else
130
- expect_type(type, val_class, prop)
128
+ expect_type(type, value, prop)
131
129
  end
132
130
  end
133
131
  end
@@ -168,13 +166,13 @@ module Airborne
168
166
  end
169
167
  end
170
168
 
171
- def expect_type(expected_type, value_class, prop_name = nil)
169
+ def expect_type(expected_type, value, prop_name = nil)
172
170
  fail ExpectationError, "Expected type #{expected_type}\nis an invalid type" if @mapper[expected_type].nil?
173
171
 
174
172
  insert = prop_name.nil? ? '' : "#{prop_name} to be of type"
175
- message = "Expected #{insert} #{expected_type}\n got #{value_class} instead"
173
+ message = "Expected #{insert} #{expected_type}\n got #{value.class} instead"
176
174
 
177
- expect(@mapper[expected_type].include?(value_class)).to eq(true), message
175
+ expect(@mapper[expected_type].any?{|type| value.is_a?(type)}).to eq(true), message
178
176
  end
179
177
 
180
178
  def convert_to_date(value)
@@ -184,10 +182,10 @@ module Airborne
184
182
  end
185
183
  end
186
184
 
187
- def check_array_types(value, value_class, prop_name, expected_type)
188
- expect_array(value_class, prop_name, expected_type)
185
+ def check_array_types(value, prop_name, expected_type)
186
+ expect_array(value, prop_name, expected_type)
189
187
  value.each do |val|
190
- expect_type(expected_type, val.class, prop_name)
188
+ expect_type(expected_type, val, prop_name)
191
189
  end
192
190
  end
193
191
 
@@ -199,8 +197,8 @@ module Airborne
199
197
  hash.is_a?(Hash) || hash.is_a?(Airborne::OptionalHashTypeExpectations)
200
198
  end
201
199
 
202
- def expect_array(value_class, prop_name, expected_type)
203
- expect(value_class).to eq(Array), "Expected #{prop_name}\n to be of type #{expected_type}\n got #{value_class} instead"
200
+ def expect_array(value, prop_name, expected_type)
201
+ expect(value.class).to eq(Array), "Expected #{prop_name}\n to be of type #{expected_type}\n got #{value.class} instead"
204
202
  end
205
203
 
206
204
  def convert_expectations_for_json_sizes(old_expectations)
@@ -230,18 +228,18 @@ module Airborne
230
228
  end
231
229
  end
232
230
 
233
- def property?(expectations)
234
- [String, Regexp, Float, *integer_types, TrueClass, FalseClass, NilClass, Array].include?(expectations.class)
231
+ def property?(expectation)
232
+ [String, Regexp, Float, Integer, TrueClass, FalseClass, NilClass, Array].any?{|type| expectation.is_a?(type)}
235
233
  end
236
234
 
237
235
  def get_mapper
238
236
  base_mapper = {
239
- integer: integer_types,
240
- array_of_integers: integer_types,
241
- int: integer_types,
242
- array_of_ints: integer_types,
243
- float: [Float, *integer_types],
244
- array_of_floats: [Float, *integer_types],
237
+ integer: [Integer],
238
+ array_of_integers: [Integer],
239
+ int: [Integer],
240
+ array_of_ints: [Integer],
241
+ float: [Float, Integer],
242
+ array_of_floats: [Float, Integer],
245
243
  string: [String],
246
244
  array_of_strings: [String],
247
245
  boolean: [TrueClass, FalseClass],
@@ -283,13 +281,5 @@ module Airborne
283
281
  def match_expected?
284
282
  Airborne.configuration.match_expected?
285
283
  end
286
-
287
- def integer_types
288
- if 0.class == Integer
289
- [Integer]
290
- else
291
- [Fixnum, Bignum]
292
- end
293
- end
294
284
  end
295
285
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airborne
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Friedman
@@ -110,7 +110,7 @@ dependencies:
110
110
  description:
111
111
  email:
112
112
  - a.friedman07@gmail.com
113
- - teampollack@gmail.com
113
+ - seth@sethpollack.net
114
114
  executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []