airborne 0.1.3 → 0.1.4

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: 486fe6abca542928748456f3d900ac4aaea5c26a
4
- data.tar.gz: 9b8c95a34c4a2fe711151c9490fda2076faf9e98
3
+ metadata.gz: eb2cc7c750235264547682073bf9a99fc30eb027
4
+ data.tar.gz: ea66ce3a100d4078abcadaa4c832b840d7187f66
5
5
  SHA512:
6
- metadata.gz: 4f22bd4edc12c5c691c3b046327ed75473038bf86ca9265a7e4eca939d2f883311eff8681d806fe0d4928649bec2f5f2ab4e96e7c95acadf6e2ed7282380b1f6
7
- data.tar.gz: 5fcb3767a985b301aa7e1d696b80f1aafc11aebdb27e994f64cf137fd67f8b7a82cc835c38d16c146cf52440174b8c16c40afcc4c81fbb79e97c9a4d260723be
6
+ metadata.gz: e13485b10fcff3a67558501f82a70f0cd0dd12b0cffcfd0275990107ba115715719a6e26a0dc85b9ba60308003e38553047c1aa34d770e47e9a8a3fd7c9bf903
7
+ data.tar.gz: fc929249c14d7549170299591e6336474677d1db7f1b5c4d28d9d5eb67127fa045a9601b4136df287be839a4bad891deec4cc77a1ca2dafa73590265af511b21
data/.gitignore CHANGED
@@ -26,11 +26,11 @@ build/
26
26
 
27
27
  # for a library or gem, you might want to ignore these files since the code is
28
28
  # intended to run in multiple environments; otherwise, check them in:
29
- # Gemfile.lock
29
+ Gemfile.lock
30
30
  # .ruby-version
31
31
  # .ruby-gemset
32
32
 
33
33
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
34
  .rvmrc
35
35
  .idea
36
- .DS_store
36
+ .DS_store
data/README.md CHANGED
@@ -14,7 +14,7 @@ RSpec driven API testing framework inspired by [frisby.js](https://github.com/vl
14
14
  Install Airborne:
15
15
 
16
16
  gem install airborne
17
-
17
+
18
18
  Or add it to your Gemfile:
19
19
 
20
20
  gem 'airborne'
@@ -26,12 +26,12 @@ require 'airborne'
26
26
 
27
27
  describe 'sample spec' do
28
28
  it 'should validate types' do
29
- get 'http://example.com/api/v1/simple_get' #json api that returns { "name" : "John Doe" }
29
+ get 'http://example.com/api/v1/simple_get' #json api that returns { "name" : "John Doe" }
30
30
  expect_json_types({name: :string})
31
31
  end
32
32
 
33
- it 'should validate values' do
34
- get 'http://example.com/api/v1/simple_get' #json api that returns { "name" : "John Doe" }
33
+ it 'should validate values' do
34
+ get 'http://example.com/api/v1/simple_get' #json api that returns { "name" : "John Doe" }
35
35
  expect_json({:name => "John Doe"})
36
36
  end
37
37
  end
@@ -54,7 +54,7 @@ When calling expect_json_types, these are the valid types that can be tested aga
54
54
  * `:array_of_arrays`
55
55
 
56
56
  If the properties are optional and may not appear in the response, you can append `_or_null` to the types above.
57
-
57
+
58
58
  ```ruby
59
59
  describe 'sample spec' do
60
60
  it 'should validate types' do
@@ -108,7 +108,7 @@ end
108
108
 
109
109
  ##Making requests
110
110
 
111
- 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`. This will then give you access the following properties:
111
+ 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`. This will then give you access the following properties:
112
112
 
113
113
  * `response` - The HTTP response returned from the request
114
114
  * `headers` - A symbolized hash of the response headers returned by the request
@@ -119,20 +119,20 @@ For example:
119
119
 
120
120
  ```ruby
121
121
  it 'should validate types' do
122
- get 'http://example.com/api/v1/simple_get' #json api that returns { "name" : "John Doe" }
122
+ get 'http://example.com/api/v1/simple_get' #json api that returns { "name" : "John Doe" }
123
123
  name = json_body[:name] #name will equal "John Doe"
124
124
  body_as_string = body
125
125
  end
126
126
  ```
127
127
 
128
- When calling any of the methods above, you can pass request headers to be used.
128
+ When calling any of the methods above, you can pass request headers to be used.
129
129
 
130
130
  ```ruby
131
131
  get 'http://example.com/api/v1/my_api', {'x-auth-token' => 'my_token'}
132
132
  ```
133
133
 
134
134
  For requests that require a body (`post`, `put`, `patch`) you can pass the body as a hash as well:
135
-
135
+
136
136
  ```ruby
137
137
  post 'http://example.com/api/v1/my_api', {:name => 'John Doe'}, {'x-auth-token' => 'my_token'}
138
138
  ```
@@ -147,7 +147,7 @@ Airborne.configure do |config|
147
147
  end
148
148
  ```
149
149
 
150
- Under the covers, Airborne uses [rack-test](https://github.com/brynary/rack-test) to make the requests.
150
+ Under the covers, Airborne uses [rack-test](https://github.com/brynary/rack-test) to make the requests.
151
151
 
152
152
  ##Rails Applications
153
153
 
@@ -179,7 +179,7 @@ end
179
179
 
180
180
  ##Path Matching
181
181
 
182
- When calling `expect_json_types`, `expect_json`, `expect_json_keys` or `expect_json_sizes` you can optionally specify a path as a first parameter.
182
+ When calling `expect_json_types`, `expect_json`, `expect_json_keys` or `expect_json_sizes` you can optionally specify a path as a first parameter.
183
183
 
184
184
  For example, if our API returns the following JSON:
185
185
 
@@ -197,9 +197,9 @@ For example, if our API returns the following JSON:
197
197
  }
198
198
  }
199
199
  ```
200
-
200
+
201
201
  This test would only test the address object:
202
-
202
+
203
203
  ```ruby
204
204
  describe 'path spec' do
205
205
  it 'should allow simple path and verify only that path' do
@@ -215,7 +215,7 @@ Or, to test the existence of specific keys:
215
215
  ```ruby
216
216
  it 'should allow nested paths' do
217
217
  get 'http://example.com/api/v1/simple_path_get'
218
- expect_json_keys('address', [:street, :city, :state, :coordinates])
218
+ expect_json_keys('address', [:street, :city, :state, :coordinates])
219
219
  end
220
220
  ```
221
221
 
@@ -224,7 +224,7 @@ Alternativley, if we only want to test `coordinates` we can dot into just the `c
224
224
  ```ruby
225
225
  it 'should allow nested paths' do
226
226
  get 'http://example.com/api/v1/simple_path_get'
227
- expect_json('address.coordinates', {latitude: 33.3872, longitude: 104.5281} )
227
+ expect_json('address.coordinates', {latitude: 33.3872, longitude: 104.5281} )
228
228
  end
229
229
  ```
230
230
 
@@ -250,7 +250,7 @@ Given the following JSON:
250
250
  We can test against just the first car like this:
251
251
 
252
252
  ```ruby
253
- it 'should index into array and test against specific element' do
253
+ it 'should index into array and test against specific element' do
254
254
  get '/array_api'
255
255
  expect_json('cars.0', {make: "Tesla", model: "Model S"})
256
256
  end
@@ -259,13 +259,13 @@ end
259
259
  To test the types of all elements in the array:
260
260
 
261
261
  ```ruby
262
- it 'should test all elements of the array' do
262
+ it 'should test all elements of the array' do
263
263
  get 'http://example.com/api/v1/array_api'
264
264
  expect_json('cars.?', {make: "Tesla", model: "Model S"}) # tests that one car in array matches the tesla
265
265
  expect_json_types('cars.*', {make: :string, model: :string}) # tests all cars in array for make and model of type string
266
266
  end
267
267
  ```
268
-
268
+
269
269
  `*` and `?` work for nested arrays as well. Given the following JSON:
270
270
 
271
271
  ```json
@@ -319,7 +319,7 @@ it 'should verify correct date value' do
319
319
  prev_day = DateTime.new(2014,10,19)
320
320
  next_day = DateTime.new(2014,10,21)
321
321
  #within the date callback, you can use regular RSpec expectations that work with dates
322
- expect_json({createdAt: date {|value| expect(value).to be_between(prev_day, next_day)}})
322
+ expect_json({createdAt: date {|value| expect(value).to be_between(prev_day, next_day)}})
323
323
  end
324
324
  ```
325
325
 
@@ -354,8 +354,8 @@ end
354
354
 
355
355
  $ cd your/project
356
356
  $ rspec spec
357
-
358
- ## License
357
+
358
+ ## License
359
359
 
360
360
  The MIT License
361
361
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'airborne'
3
- s.version = '0.1.3'
4
- s.date = '2014-11-17'
3
+ s.version = '0.1.4'
4
+ s.date = '2014-11-24'
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']
@@ -44,6 +44,13 @@ module Airborne
44
44
  set_response(make_request(:delete, url, {headers: headers}))
45
45
  end
46
46
 
47
+ def head(url, headers = nil)
48
+ set_response(make_request(:head, url, {headers: headers}))
49
+ end
50
+
51
+ def options()
52
+ end
53
+
47
54
  def response
48
55
  @response
49
56
  end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'head' do
4
+ it 'should allow testing on head requests' do
5
+ mock_head('simple_head', {'foo' => 'foo'})
6
+ head '/simple_head', {}
7
+ expect_status(200)
8
+ expect_header('foo', 'foo')
9
+ expect(json_body).to be(nil)
10
+ end
11
+ end
@@ -29,9 +29,13 @@ module StubHelper
29
29
  stub_request(:delete, @base_url + url)
30
30
  end
31
31
 
32
+ def mock_head(url, response_headers = {}, status = 200)
33
+ stub_request(:head, @base_url + url).to_return(headers: response_headers, body: nil, status: status)
34
+ end
35
+
32
36
  private
33
37
 
34
38
  def get_json_response_file(name)
35
39
  IO.read(File.join('spec/test_responses', name + ".json"))
36
40
  end
37
- end
41
+ 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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Friedman
@@ -9,94 +9,94 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-17 00:00:00.000000000 Z
12
+ date: 2014-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
20
  version: '3.1'
21
- - - ">="
21
+ - - '>='
22
22
  - !ruby/object:Gem::Version
23
23
  version: 3.1.0
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - "~>"
28
+ - - ~>
29
29
  - !ruby/object:Gem::Version
30
30
  version: '3.1'
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.1.0
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rest-client
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.7'
41
- - - ">="
41
+ - - '>='
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.7.2
44
44
  type: :runtime
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - "~>"
48
+ - - ~>
49
49
  - !ruby/object:Gem::Version
50
50
  version: '1.7'
51
- - - ">="
51
+ - - '>='
52
52
  - !ruby/object:Gem::Version
53
53
  version: 1.7.2
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: rack-test
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ~>
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0.6'
61
- - - ">="
61
+ - - '>='
62
62
  - !ruby/object:Gem::Version
63
63
  version: 0.6.2
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - "~>"
68
+ - - ~>
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0.6'
71
- - - ">="
71
+ - - '>='
72
72
  - !ruby/object:Gem::Version
73
73
  version: 0.6.2
74
74
  - !ruby/object:Gem::Dependency
75
75
  name: activesupport
76
76
  requirement: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - ">="
78
+ - - '>='
79
79
  - !ruby/object:Gem::Version
80
80
  version: 4.0.1
81
81
  type: :runtime
82
82
  prerelease: false
83
83
  version_requirements: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - ">="
85
+ - - '>='
86
86
  - !ruby/object:Gem::Version
87
87
  version: 4.0.1
88
88
  - !ruby/object:Gem::Dependency
89
89
  name: webmock
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - "~>"
92
+ - - ~>
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  type: :development
96
96
  prerelease: false
97
97
  version_requirements: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - "~>"
99
+ - - ~>
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  description:
@@ -107,12 +107,10 @@ executables: []
107
107
  extensions: []
108
108
  extra_rdoc_files: []
109
109
  files:
110
- - ".coveralls.yml"
111
- - ".gitignore"
112
- - ".travis.yml"
113
- - CHANGELOG.md
110
+ - .coveralls.yml
111
+ - .gitignore
112
+ - .travis.yml
114
113
  - Gemfile
115
- - Gemfile.lock
116
114
  - LICENSE
117
115
  - README.md
118
116
  - airborne.gemspec
@@ -140,6 +138,7 @@ files:
140
138
  - spec/airborne/expectations/expect_json_types_path_spec.rb
141
139
  - spec/airborne/expectations/expect_json_types_spec.rb
142
140
  - spec/airborne/expectations/expect_status_spec.rb
141
+ - spec/airborne/head_spec.rb
143
142
  - spec/airborne/patch_spec.rb
144
143
  - spec/airborne/post_spec.rb
145
144
  - spec/airborne/put_spec.rb
@@ -170,17 +169,17 @@ require_paths:
170
169
  - lib
171
170
  required_ruby_version: !ruby/object:Gem::Requirement
172
171
  requirements:
173
- - - ">="
172
+ - - '>='
174
173
  - !ruby/object:Gem::Version
175
174
  version: '0'
176
175
  required_rubygems_version: !ruby/object:Gem::Requirement
177
176
  requirements:
178
- - - ">="
177
+ - - '>='
179
178
  - !ruby/object:Gem::Version
180
179
  version: '0'
181
180
  requirements: []
182
181
  rubyforge_project:
183
- rubygems_version: 2.2.0
182
+ rubygems_version: 2.4.1
184
183
  signing_key:
185
184
  specification_version: 4
186
185
  summary: RSpec driven API testing framework
@@ -1,8 +0,0 @@
1
-
2
- ## Unreleased
3
-
4
- ### enhancements
5
-
6
- - Add new API `expect_json_sizes` for testing sizes of JSON values
7
-
8
- ### bug fixes
@@ -1,79 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- activesupport (4.1.6)
5
- i18n (~> 0.6, >= 0.6.9)
6
- json (~> 1.7, >= 1.7.7)
7
- minitest (~> 5.1)
8
- thread_safe (~> 0.1)
9
- tzinfo (~> 1.1)
10
- addressable (2.3.6)
11
- coveralls (0.7.1)
12
- multi_json (~> 1.3)
13
- rest-client
14
- simplecov (>= 0.7)
15
- term-ansicolor
16
- thor
17
- crack (0.4.2)
18
- safe_yaml (~> 1.0.0)
19
- diff-lcs (1.2.5)
20
- docile (1.1.5)
21
- i18n (0.6.11)
22
- json (1.8.1)
23
- mime-types (2.3)
24
- minitest (5.4.1)
25
- multi_json (1.10.1)
26
- netrc (0.7.7)
27
- rack (1.5.2)
28
- rack-protection (1.5.3)
29
- rack
30
- rack-test (0.6.2)
31
- rack (>= 1.0)
32
- rest-client (1.7.2)
33
- mime-types (>= 1.16, < 3.0)
34
- netrc (~> 0.7)
35
- rspec (3.1.0)
36
- rspec-core (~> 3.1.0)
37
- rspec-expectations (~> 3.1.0)
38
- rspec-mocks (~> 3.1.0)
39
- rspec-core (3.1.3)
40
- rspec-support (~> 3.1.0)
41
- rspec-expectations (3.1.1)
42
- diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.1.0)
44
- rspec-mocks (3.1.0)
45
- rspec-support (~> 3.1.0)
46
- rspec-support (3.1.0)
47
- safe_yaml (1.0.3)
48
- simplecov (0.9.0)
49
- docile (~> 1.1.0)
50
- multi_json
51
- simplecov-html (~> 0.8.0)
52
- simplecov-html (0.8.0)
53
- sinatra (1.4.5)
54
- rack (~> 1.4)
55
- rack-protection (~> 1.4)
56
- tilt (~> 1.3, >= 1.3.4)
57
- term-ansicolor (1.3.0)
58
- tins (~> 1.0)
59
- thor (0.19.1)
60
- thread_safe (0.3.4)
61
- tilt (1.4.1)
62
- tins (1.3.3)
63
- tzinfo (1.2.2)
64
- thread_safe (~> 0.1)
65
- webmock (1.18.0)
66
- addressable (>= 2.3.6)
67
- crack (>= 0.3.2)
68
-
69
- PLATFORMS
70
- ruby
71
-
72
- DEPENDENCIES
73
- activesupport
74
- coveralls
75
- rack-test
76
- rest-client
77
- rspec
78
- sinatra
79
- webmock