airborne 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +9 -8
- data/airborne.gemspec +1 -1
- data/lib/airborne/request_expectations.rb +15 -7
- 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: 76d1f2d5892782be324dedfac91cce34f4afe075
|
4
|
+
data.tar.gz: 30a16b7055de4ac3662454d05caacf645640cb0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 530db301f9293ce05f59531e758d1f5da77a53e584f041d391c99866c917c192a188773b81dfc9505240ab03539eea51292e90a12445e760af48d4ac588ee3db
|
7
|
+
data.tar.gz: 96d100dfeb6c6a5086a1787acbfba797281d81d6b2b68bce4fea8a2665ed466b4e464a665d8f83ca779a1f813abcb44fb5afff8e8781f18495c90a4a1605c05d
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Or add it to your Gemfile:
|
|
19
19
|
```ruby
|
20
20
|
gem 'airborne'
|
21
21
|
```
|
22
|
-
##Creating Tests
|
22
|
+
## Creating Tests
|
23
23
|
|
24
24
|
```ruby
|
25
25
|
require 'airborne'
|
@@ -107,7 +107,7 @@ describe 'sample spec' do
|
|
107
107
|
end
|
108
108
|
```
|
109
109
|
|
110
|
-
##Making requests
|
110
|
+
## Making requests
|
111
111
|
|
112
112
|
Airborne uses `rest_client` to make the HTTP request, and supports all HTTP verbs. When creating a test, you can call any of the following methods: `get`, `post`, `put`, `patch`, `delete`, `head`, `options`. This will then give you access the following properties:
|
113
113
|
|
@@ -144,7 +144,7 @@ For requests that require Query params you can pass a params hash into headers.
|
|
144
144
|
post 'http://example.com/api/v1/my_api', { }, { 'params' => {'param_key' => 'param_value' } }
|
145
145
|
```
|
146
146
|
|
147
|
-
##Testing Rack Applications
|
147
|
+
## Testing Rack Applications
|
148
148
|
|
149
149
|
If you have an existing Rack application like `sinatra` or `grape` you can run Airborne against your application and test without actually having a server running. To do that, just specify your rack application in your Airborne configuration:
|
150
150
|
|
@@ -156,7 +156,7 @@ end
|
|
156
156
|
|
157
157
|
Under the covers, Airborne uses [rack-test](https://github.com/brynary/rack-test) to make the requests.
|
158
158
|
|
159
|
-
##Rails Applications
|
159
|
+
## Rails Applications
|
160
160
|
|
161
161
|
If you're testing an API you've written in Rails, Airborne plays along with `rspec-rails`:
|
162
162
|
|
@@ -174,7 +174,7 @@ RSpec.describe HomeController, :type => :controller do
|
|
174
174
|
end
|
175
175
|
```
|
176
176
|
|
177
|
-
##API
|
177
|
+
## API
|
178
178
|
|
179
179
|
* `expect_json_types` - Tests the types of the JSON property values returned
|
180
180
|
* `expect_json` - Tests the values of the JSON property values returned
|
@@ -184,7 +184,7 @@ end
|
|
184
184
|
* `expect_header` - Tests for a specified header in the response
|
185
185
|
* `expect_header_contains` - Partial match test on a specified header
|
186
186
|
|
187
|
-
##Path Matching
|
187
|
+
## Path Matching
|
188
188
|
|
189
189
|
When calling `expect_json_types`, `expect_json`, `expect_json_keys` or `expect_json_sizes` you can optionally specify a path as a first parameter.
|
190
190
|
|
@@ -309,7 +309,8 @@ it 'should check all nested arrays for specified elements' do
|
|
309
309
|
end
|
310
310
|
```
|
311
311
|
|
312
|
-
##Dates
|
312
|
+
## Dates
|
313
|
+
|
313
314
|
JSON has no support for dates, however airborne gives you the ability to check for dates using the following. For `expect_json_types` you would use it as you would for any of the other types:
|
314
315
|
|
315
316
|
```ruby
|
@@ -330,7 +331,7 @@ it 'should verify correct date value' do
|
|
330
331
|
end
|
331
332
|
```
|
332
333
|
|
333
|
-
##Configuration
|
334
|
+
## Configuration
|
334
335
|
|
335
336
|
When setting up Airborne, you can call `configure` just like you would with `rspec`:
|
336
337
|
|
data/airborne.gemspec
CHANGED
@@ -231,17 +231,17 @@ module Airborne
|
|
231
231
|
end
|
232
232
|
|
233
233
|
def property?(expectations)
|
234
|
-
[String, Regexp, Float,
|
234
|
+
[String, Regexp, Float, *integer_types, TrueClass, FalseClass, NilClass, Array].include?(expectations.class)
|
235
235
|
end
|
236
236
|
|
237
237
|
def get_mapper
|
238
238
|
base_mapper = {
|
239
|
-
integer:
|
240
|
-
array_of_integers:
|
241
|
-
int:
|
242
|
-
array_of_ints:
|
243
|
-
float: [Float,
|
244
|
-
array_of_floats: [Float,
|
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],
|
245
245
|
string: [String],
|
246
246
|
array_of_strings: [String],
|
247
247
|
boolean: [TrueClass, FalseClass],
|
@@ -283,5 +283,13 @@ module Airborne
|
|
283
283
|
def match_expected?
|
284
284
|
Airborne.configuration.match_expected?
|
285
285
|
end
|
286
|
+
|
287
|
+
def integer_types
|
288
|
+
if 0.class == Integer
|
289
|
+
[Integer]
|
290
|
+
else
|
291
|
+
[Fixnum, Bignum]
|
292
|
+
end
|
293
|
+
end
|
286
294
|
end
|
287
295
|
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.
|
4
|
+
version: 0.2.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: 2017-
|
12
|
+
date: 2017-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|