airborne 0.0.21 → 0.0.22

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.
@@ -1,15 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'expect_status' do
4
- it 'should verify correct status code' do
5
- mock_get('simple_get')
6
- get '/simple_get'
7
- expect_status(200)
8
- end
4
+ it 'should verify correct status code' do
5
+ mock_get('simple_get')
6
+ get '/simple_get'
7
+ expect_status(200)
8
+ end
9
9
 
10
- it 'should fail when incorrect status code is returned' do
11
- mock_get('simple_get')
12
- get '/simple_get'
13
- expect{expect_status(123)}.to raise_error
14
- end
10
+ it 'should fail when incorrect status code is returned' do
11
+ mock_get('simple_get')
12
+ get '/simple_get'
13
+ expect{expect_status(123)}.to raise_error
14
+ end
15
15
  end
@@ -1,35 +1,35 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'expect header' do
4
- it 'should find exact match for header content' do
5
- mock_get('simple_get', {'Content-Type' => 'application/json'})
6
- get '/simple_get'
7
- expect_header(:content_type, 'application/json')
8
- end
4
+ it 'should find exact match for header content' do
5
+ mock_get('simple_get', {'Content-Type' => 'application/json'})
6
+ get '/simple_get'
7
+ expect_header(:content_type, 'application/json')
8
+ end
9
9
 
10
- it 'should ensure correct headers are present' do
11
- mock_get('simple_get', {'Content-Type' => 'application/json'})
12
- get '/simple_get'
13
- expect{expect_header(:foo, 'bar')}.to raise_error
14
- end
10
+ it 'should ensure correct headers are present' do
11
+ mock_get('simple_get', {'Content-Type' => 'application/json'})
12
+ get '/simple_get'
13
+ expect{expect_header(:foo, 'bar')}.to raise_error
14
+ end
15
15
  end
16
16
 
17
17
  describe 'expect header contains' do
18
- it 'should ensure partial header match exists' do
19
- mock_get('simple_get', {'Content-Type' => 'application/json'})
20
- get '/simple_get'
21
- expect_header_contains(:content_type, 'json')
22
- end
18
+ it 'should ensure partial header match exists' do
19
+ mock_get('simple_get', {'Content-Type' => 'application/json'})
20
+ get '/simple_get'
21
+ expect_header_contains(:content_type, 'json')
22
+ end
23
23
 
24
- it 'should ensure header is present' do
25
- mock_get('simple_get', {'Content-Type' => 'application/json'})
26
- get '/simple_get'
27
- expect{expect_header_contains(:foo, 'bar')}.to raise_error
28
- end
24
+ it 'should ensure header is present' do
25
+ mock_get('simple_get', {'Content-Type' => 'application/json'})
26
+ get '/simple_get'
27
+ expect{expect_header_contains(:foo, 'bar')}.to raise_error
28
+ end
29
29
 
30
- it 'should ensure partial header is present' do
31
- mock_get('simple_get', {'Content-Type' => 'application/json'})
32
- get '/simple_get'
33
- expect{expect_header_contains(:content_type, 'bar')}.to raise_error
34
- end
30
+ it 'should ensure partial header is present' do
31
+ mock_get('simple_get', {'Content-Type' => 'application/json'})
32
+ get '/simple_get'
33
+ expect{expect_header_contains(:content_type, 'bar')}.to raise_error
34
+ end
35
35
  end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'patch' do
4
- it 'should allow testing on patch requests' do
5
- mock_patch('simple_patch')
6
- patch '/simple_patch', {}
7
- expect_json_types({status: :string, someNumber: :int})
8
- end
4
+ it 'should allow testing on patch requests' do
5
+ mock_patch('simple_patch')
6
+ patch '/simple_patch', {}
7
+ expect_json_types({status: :string, someNumber: :int})
8
+ end
9
9
  end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'post' do
4
- it 'should allow testing on post requests' do
5
- mock_post('simple_post')
6
- post '/simple_post', {}
7
- expect_json_types({status: :string, someNumber: :int})
8
- end
4
+ it 'should allow testing on post requests' do
5
+ mock_post('simple_post')
6
+ post '/simple_post', {}
7
+ expect_json_types({status: :string, someNumber: :int})
8
+ end
9
9
  end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'put' do
4
- it 'should allow testing on put requests' do
5
- mock_put('simple_put')
6
- put '/simple_put', {}
7
- expect_json_types({status: :string, someNumber: :int})
8
- end
4
+ it 'should allow testing on put requests' do
5
+ mock_put('simple_put')
6
+ put '/simple_put', {}
7
+ expect_json_types({status: :string, someNumber: :int})
8
+ end
9
9
  end
@@ -2,26 +2,26 @@ require 'json'
2
2
  require 'sinatra'
3
3
 
4
4
  class SampleApp < Sinatra::Application
5
- before do
6
- content_type 'application/json'
7
- end
8
- get '/' do
9
- {foo: "bar"}.to_json
10
- end
5
+ before do
6
+ content_type 'application/json'
7
+ end
8
+ get '/' do
9
+ {foo: "bar"}.to_json
10
+ end
11
11
  end
12
12
 
13
13
  Airborne.configure do |config|
14
- config.rack_app = SampleApp
14
+ config.rack_app = SampleApp
15
15
  end
16
16
 
17
17
  describe 'rack app' do
18
- it 'should allow requests against a sinatra app' do
19
- get '/'
20
- expect_json_types({foo: :string})
21
- end
18
+ it 'should allow requests against a sinatra app' do
19
+ get '/'
20
+ expect_json_types({foo: :string})
21
+ end
22
22
 
23
- it 'should ensure correct values from sinatra app' do
24
- get '/'
25
- expect{expect_json_types({foo: :int})}.to raise_error
26
- end
23
+ it 'should ensure correct values from sinatra app' do
24
+ get '/'
25
+ expect{expect_json_types({foo: :int})}.to raise_error
26
+ end
27
27
  end
@@ -4,7 +4,7 @@ require 'airborne'
4
4
  require 'stub_helper'
5
5
 
6
6
  Airborne.configure do |config|
7
- config.base_url = 'http://www.example.com'
8
- config.include StubHelper
7
+ config.base_url = 'http://www.example.com'
8
+ config.include StubHelper
9
9
  end
10
10
 
@@ -2,36 +2,36 @@ require 'webmock/rspec'
2
2
 
3
3
  module StubHelper
4
4
 
5
- def initialize
6
- @base_url = 'http://www.example.com/'
7
- end
8
-
9
- def mock_get(url, response_headers = {}, status = 200)
10
- stub_request(:get, @base_url + url).to_return(headers: response_headers, body: get_json_response_file(url), status: status)
11
- end
12
-
13
- def mock_post(url, options = {}, status = 200)
14
- stub_request(:post, @base_url + url).with(body: options[:request_body] || {})
15
- .to_return(headers: options[:response_headers] || {}, body: get_json_response_file(url), status: status)
16
- end
17
-
18
- def mock_put(url, options = {}, status = 200)
19
- stub_request(:put, @base_url + url).with(body: options[:request_body] || {})
20
- .to_return(headers: options[:response_headers] || {}, body: get_json_response_file(url), status: status)
21
- end
22
-
23
- def mock_patch(url, options = {}, status = 200)
24
- stub_request(:patch, @base_url + url).with(body: options[:request_body] || {})
25
- .to_return(headers: options[:response_headers] || {}, body: get_json_response_file(url), status: status)
26
- end
27
-
28
- def mock_delete(url)
29
- stub_request(:delete, @base_url + url)
30
- end
31
-
32
- private
33
-
34
- def get_json_response_file(name)
35
- IO.read(File.join('spec/test_responses', name + ".json"))
36
- end
5
+ def initialize
6
+ @base_url = 'http://www.example.com/'
7
+ end
8
+
9
+ def mock_get(url, response_headers = {}, status = 200)
10
+ stub_request(:get, @base_url + url).to_return(headers: response_headers, body: get_json_response_file(url), status: status)
11
+ end
12
+
13
+ def mock_post(url, options = {}, status = 200)
14
+ stub_request(:post, @base_url + url).with(body: options[:request_body] || {})
15
+ .to_return(headers: options[:response_headers] || {}, body: get_json_response_file(url), status: status)
16
+ end
17
+
18
+ def mock_put(url, options = {}, status = 200)
19
+ stub_request(:put, @base_url + url).with(body: options[:request_body] || {})
20
+ .to_return(headers: options[:response_headers] || {}, body: get_json_response_file(url), status: status)
21
+ end
22
+
23
+ def mock_patch(url, options = {}, status = 200)
24
+ stub_request(:patch, @base_url + url).with(body: options[:request_body] || {})
25
+ .to_return(headers: options[:response_headers] || {}, body: get_json_response_file(url), status: status)
26
+ end
27
+
28
+ def mock_delete(url)
29
+ stub_request(:delete, @base_url + url)
30
+ end
31
+
32
+ private
33
+
34
+ def get_json_response_file(name)
35
+ IO.read(File.join('spec/test_responses', name + ".json"))
36
+ end
37
37
  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.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Friedman
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  requirements: []
170
170
  rubyforge_project:
171
- rubygems_version: 2.1.5
171
+ rubygems_version: 2.2.0
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: RSpec driven API testing framework