airborne 0.0.19 → 0.0.20
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/README.md +11 -0
- data/airborne.gemspec +1 -1
- data/lib/airborne/request_expectations.rb +7 -2
- data/spec/airborne/expect_json_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72800611382a9339603e8e316774b92c7afadc09
|
4
|
+
data.tar.gz: 522ad81904bc8644e5b3f4bddeaa9551dfa9c5a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f4a73c106f9d9492ca973815d85f383107010affbf3a37d5db6d7e074c48fb6623e74f693cf550e8d6971f0cf24235af42e310cfbeb37fb1f98542a93f50481
|
7
|
+
data.tar.gz: 2dc74d2d76a6bd1a3f424b9b563d3e4ea9ea68ecb84c0591b50d1e31b29860406edddb21d1fbc42c643397fcff8e5cedf13ef1524821af01a077fab5a7275fe8
|
data/README.md
CHANGED
@@ -71,6 +71,17 @@ it 'should allow optional nested hash' do
|
|
71
71
|
end
|
72
72
|
```
|
73
73
|
|
74
|
+
Additionally, when calling `expect_json`, you can provide a regex pattern in a call to `regex`:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
describe 'sample spec' do
|
78
|
+
it 'should validate types' do
|
79
|
+
get 'http://example.com/api/v1/simple_get' #json api that returns { "name" : "John Doe" }
|
80
|
+
expect_json({name: regex("^John")})
|
81
|
+
end
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
74
85
|
When calling `expect_json` or `expect_json_types`, you can optionally provide a block and run your own `rspec` expectations:
|
75
86
|
|
76
87
|
```ruby
|
data/airborne.gemspec
CHANGED
@@ -49,6 +49,10 @@ module Airborne
|
|
49
49
|
OptionalHashTypeExpectations.new(hash)
|
50
50
|
end
|
51
51
|
|
52
|
+
def regex(reg)
|
53
|
+
Regexp.new(reg)
|
54
|
+
end
|
55
|
+
|
52
56
|
private
|
53
57
|
|
54
58
|
def call_with_path(args)
|
@@ -115,11 +119,12 @@ module Airborne
|
|
115
119
|
expect_json_impl(expected_value, actual_value)
|
116
120
|
elsif expected_value.class == Proc
|
117
121
|
expected_value.call(actual_value)
|
122
|
+
elsif expected_value.class == Regexp
|
123
|
+
expect(actual_value).to match(expected_value)
|
118
124
|
else
|
119
|
-
expect(
|
125
|
+
expect(actual_value).to eq(expected_value)
|
120
126
|
end
|
121
127
|
end
|
122
128
|
end
|
123
|
-
|
124
129
|
end
|
125
130
|
end
|
@@ -50,4 +50,16 @@ describe 'expect_json' do
|
|
50
50
|
expect_json({name: -> (name){expect(name.length).to eq(4)}})
|
51
51
|
end
|
52
52
|
|
53
|
+
it 'should test against regex' do
|
54
|
+
mock_get('simple_get')
|
55
|
+
get '/simple_get'
|
56
|
+
expect_json({name: regex("^A")})
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should raise an error if regex does not match' do
|
60
|
+
mock_get('simple_get')
|
61
|
+
get '/simple_get'
|
62
|
+
expect{expect_json({name: regex("^B")})}.to raise_error
|
63
|
+
end
|
64
|
+
|
53
65
|
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.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Friedman
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
176
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.2.0
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: RSpec driven API testing framework
|