airborne 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/airborne.gemspec +2 -2
- data/lib/airborne/path_matcher.rb +2 -2
- data/spec/airborne/path_spec.rb +26 -11
- data/spec/test_responses/numeric_property.json +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f3a95dbd602655f5f9912cf0dd7c4e09be76368
|
4
|
+
data.tar.gz: b72232f7b1ca118d77a9c0bd9b42dea8cc6e7674
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b964ae3224bfba3a4db3534db6b241478743742efc8e5507f9f68a3ba25b5bb5f87b6c6f8b60af625c2ffcae5e0cad9147907751af40c52b9c315ce8a68b0deb
|
7
|
+
data.tar.gz: 1301b091fa0d7a1119147738427091d131101d4a4fbb0c63c1af13d4dfe6a809be041a540eb31fff65e4c03ef689a82fb7c1ffe942b1a3c9e1da2daef26ae99f
|
data/airborne.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'airborne'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '
|
3
|
+
s.version = '0.1.10'
|
4
|
+
s.date = '2015-01-06'
|
5
5
|
s.summary = "RSpec driven API testing framework"
|
6
6
|
s.authors = ["Alex Friedman", "Seth Pollack"]
|
7
7
|
s.email = ['a.friedman07@gmail.com', 'teampollack@gmail.com']
|
@@ -3,7 +3,7 @@ module Airborne
|
|
3
3
|
module PathMatcher
|
4
4
|
|
5
5
|
def get_by_path(path, json, &block)
|
6
|
-
raise PathError, "
|
6
|
+
raise PathError, "Invalid Path, contains '..'" if /\.\./ =~ path
|
7
7
|
type = false
|
8
8
|
parts = path.split('.')
|
9
9
|
parts.each_with_index do |part, index|
|
@@ -51,7 +51,7 @@ module Airborne
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def process_json(part, json)
|
54
|
-
if is_index?(part)
|
54
|
+
if is_index?(part) && json.is_a?(Array)
|
55
55
|
part = part.to_i
|
56
56
|
json = json[part]
|
57
57
|
else
|
data/spec/airborne/path_spec.rb
CHANGED
@@ -2,20 +2,35 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'expect path' do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
describe "errors" do
|
6
|
+
before :each do
|
7
|
+
mock_get('array_with_index')
|
8
|
+
get '/array_with_index'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should raise PathError when incorrect path containing .. is used" do
|
12
|
+
expect do
|
13
|
+
expect_json('cars..make', "Tesla")
|
14
|
+
end.to raise_error(Airborne::PathError, "Invalid Path, contains '..'")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should raise PathError when trying to call property on an array" do
|
18
|
+
expect do
|
19
|
+
expect_json('cars.make', "Tesla")
|
20
|
+
end.to raise_error(Airborne::PathError, "Expected Array\nto to be an object with property make")
|
21
|
+
end
|
8
22
|
end
|
9
23
|
|
10
|
-
it "should
|
11
|
-
|
12
|
-
|
13
|
-
|
24
|
+
it "should work with numberic properties" do
|
25
|
+
mock_get('numeric_property')
|
26
|
+
get '/numeric_property'
|
27
|
+
expect_json('cars.0.make', "Tesla")
|
14
28
|
end
|
15
29
|
|
16
|
-
it "should
|
17
|
-
|
18
|
-
|
19
|
-
|
30
|
+
it "should work with numberic properties" do
|
31
|
+
mock_get('numeric_property')
|
32
|
+
get '/numeric_property'
|
33
|
+
expect_json_keys('cars.0',[:make, :model])
|
20
34
|
end
|
35
|
+
|
21
36
|
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.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Friedman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- spec/test_responses/array_with_nested_bad_data.json
|
156
156
|
- spec/test_responses/date_response.json
|
157
157
|
- spec/test_responses/invalid_get.json
|
158
|
+
- spec/test_responses/numeric_property.json
|
158
159
|
- spec/test_responses/simple_get.json
|
159
160
|
- spec/test_responses/simple_json.json
|
160
161
|
- spec/test_responses/simple_nested_path.json
|