airborne 0.2.0 → 0.2.1

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: 7a65123aada9fd5ec28e73e1dd39a55b85b4c120
4
- data.tar.gz: df26ba37c5fa926a1c748c4c6e7b441946da49c8
3
+ metadata.gz: c6dbdb4e4fb42256d136b4fc15bc52604ec7ec55
4
+ data.tar.gz: 5babb01a3f583438d337cd63a678d6ddfb522cae
5
5
  SHA512:
6
- metadata.gz: ac97899e3eb391a2df1f4590b7a8102f7eb40d97fbe4c363ae53ee36e75e5e48ea970780e68e008f8e2af2dde2fa64181c4592128fc49d9845dc30a73125b36b
7
- data.tar.gz: 166a72d89beb9dfaa523c5ca402f4b0ca8235f696b523773bf43c381cff4b368fda5eedcb9c9b8ce7888fede5117d5e5674ead901508ce855c87d17ee0b3b249
6
+ metadata.gz: b531a941356a2861b90aa2abbcc04ce2aa68191dabe6d748275fe4ddb424b350b7ea56dd6cb625d0b3bbe93258f3fea1e20318c3e6ab2769120b0e6699f498ff
7
+ data.tar.gz: f702beedc737affede6c4b51531b2ed097b2415afba2c3cc555b4bad43cd11d348dacf71fb7c70247c5eb6fcd0c0a2367a075eaa22a133aa78d855f1c8ad3d13
data/airborne.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'airborne'
3
- s.version = '0.2.0'
3
+ s.version = '0.2.1'
4
4
  s.date = Date.today.to_s
5
5
  s.summary = 'RSpec driven API testing framework'
6
6
  s.authors = ['Alex Friedman', 'Seth Pollack']
@@ -85,7 +85,7 @@ module Airborne
85
85
  keys = expected.keys & actual.keys if match_none?
86
86
 
87
87
  keys.flatten.uniq.each do |prop|
88
- expected_value = extract_expected(expected, prop)
88
+ expected_value = extract_expected_value(expected, prop)
89
89
  actual_value = extract_actual(actual, prop)
90
90
 
91
91
  next expect_json_impl(expected_value, actual_value) if hash?(expected_value)
@@ -113,7 +113,7 @@ module Airborne
113
113
  keys = expected.keys & actual.keys if match_none?
114
114
 
115
115
  keys.flatten.uniq.each do |prop|
116
- type = extract_expected(expected, prop)
116
+ type = extract_expected_type(expected, prop)
117
117
  value = extract_actual(actual, prop)
118
118
  value = convert_to_date(value) if type == :date
119
119
 
@@ -140,7 +140,16 @@ module Airborne
140
140
  end
141
141
  end
142
142
 
143
- def extract_expected(expected, prop)
143
+ def extract_expected_value(expected, prop)
144
+ begin
145
+ raise unless expected.keys.include?(prop)
146
+ expected[prop]
147
+ rescue
148
+ raise ExpectationError, "Expectation is expected to contain property: #{prop}"
149
+ end
150
+ end
151
+
152
+ def extract_expected_type(expected, prop)
144
153
  begin
145
154
  type = expected[prop]
146
155
  type.nil? ? raise : type
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'expect_json options' do
4
+ describe 'match_expected', match_expected: true, match_actual: false do
5
+ it 'should require all expected properties' do
6
+ mock_get 'simple_get'
7
+ get '/simple_get'
8
+ expect{ expect_json(name: 'Alex', other: 'other') }.to raise_error(ExpectationNotMetError)
9
+ end
10
+
11
+ it 'should not require the actual properties' do
12
+ mock_get 'simple_get'
13
+ get '/simple_get'
14
+ expect_json(name: 'Alex')
15
+ end
16
+ end
17
+
18
+ describe 'match_actual', match_expected: false, match_actual: true do
19
+ it 'should require all actual properties' do
20
+ mock_get 'simple_get'
21
+ get '/simple_get'
22
+ expect{ expect_json(name: 'Alex') }.to raise_error(ExpectationError)
23
+ end
24
+
25
+ it 'should not require the expected properties' do
26
+ mock_get 'simple_get'
27
+ get '/simple_get'
28
+ expect_json(name: 'Alex', age: 32, address: nil, other: 'other')
29
+ end
30
+ end
31
+
32
+ describe 'match_both', match_expected: true, match_actual: true do
33
+ it 'should require all actual properties' do
34
+ mock_get 'simple_get'
35
+ get '/simple_get'
36
+ expect{ expect_json(name: 'Alex') }.to raise_error(ExpectationError)
37
+ end
38
+
39
+ it 'should require all expected properties' do
40
+ mock_get 'simple_get'
41
+ get '/simple_get'
42
+ expect{ expect_json(name: 'Alex', other: 'other') }.to raise_error(ExpectationNotMetError)
43
+ end
44
+ end
45
+
46
+ describe 'match_none', match_expected: false, match_actual: false do
47
+ it 'should not require the actual properties' do
48
+ mock_get 'simple_get'
49
+ get '/simple_get'
50
+ expect_json(name: 'Alex')
51
+ end
52
+
53
+ it 'should not require the expected properties' do
54
+ mock_get 'simple_get'
55
+ get '/simple_get'
56
+ expect_json(name: 'Alex', age: 32, address: nil, other: 'other')
57
+ end
58
+ end
59
+ 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.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Friedman
@@ -129,6 +129,7 @@ files:
129
129
  - spec/airborne/expectations/expect_json_keys_path_spec.rb
130
130
  - spec/airborne/expectations/expect_json_keys_spec.rb
131
131
  - spec/airborne/expectations/expect_json_lambda_spec.rb
132
+ - spec/airborne/expectations/expect_json_options_spec.rb
132
133
  - spec/airborne/expectations/expect_json_path_spec.rb
133
134
  - spec/airborne/expectations/expect_json_regex_spec.rb
134
135
  - spec/airborne/expectations/expect_json_sizes_spec.rb