airborne 0.0.19 → 0.0.20

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
  SHA1:
3
- metadata.gz: 2333bbac632fbb30333040aa0aa6bab7dc691118
4
- data.tar.gz: 4bf80a6bc014b5d8fb7a41943ad53299670a111b
3
+ metadata.gz: 72800611382a9339603e8e316774b92c7afadc09
4
+ data.tar.gz: 522ad81904bc8644e5b3f4bddeaa9551dfa9c5a0
5
5
  SHA512:
6
- metadata.gz: 014872f890830f5941401069bb62d17a1fb3006d3bb92125be375c2f32f114fc801f0edd26a3c9bee8e0fe16e7c997aeb6d509508c9c68fb27fc89a691fca826
7
- data.tar.gz: 02d23b76acb06cb0032ec63847bfaa9d06d1edb473e84d32d3e97fdf1307e197158f3e495ec2ede44df5ae01c5fc5ac9561719feca6a7a66d6ed491a0719c762
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'airborne'
3
- s.version = '0.0.19'
3
+ s.version = '0.0.20'
4
4
  s.date = '2014-09-12'
5
5
  s.summary = "RSpec driven API testing framework"
6
6
  s.authors = ["Alex Friedman", "Seth Pollack"]
@@ -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(expected_value).to eq(actual_value)
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.19
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.1.5
177
+ rubygems_version: 2.2.0
178
178
  signing_key:
179
179
  specification_version: 4
180
180
  summary: RSpec driven API testing framework