airborne 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/airborne.gemspec +1 -1
- data/lib/airborne/rest_client_requester.rb +21 -17
- data/spec/airborne/client_requester_spec.rb +36 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6f55b477b3b74d9872eb367610d368fb6b987b4
|
4
|
+
data.tar.gz: e6b5489646213522e340f9f3d0e314535dd8ef15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 127e91334701c8b69e7bdbe8430b19c903708e608147f7c67c9a9e127d8b0757d7f9fa786497ccfc3ca789b4486f061333a9490cf6a3fe82e58ffd95ef6469d5
|
7
|
+
data.tar.gz: 89693d8b556bdd84127685789ee3d38da29bc4b209f08faf4ea0e32faa482b5616730f24e8bab9f6389916dd1beec20e2f687714bb795a8245319a987eb17df5
|
data/airborne.gemspec
CHANGED
@@ -3,25 +3,29 @@ require 'rest_client'
|
|
3
3
|
module Airborne
|
4
4
|
module RestClientRequester
|
5
5
|
def make_request(method, url, options = {})
|
6
|
-
headers =
|
7
|
-
base_headers = Airborne.configuration.headers || {}
|
8
|
-
headers = base_headers.merge(headers)
|
6
|
+
headers = base_headers.merge(options[:headers] || {})
|
9
7
|
res = if method == :post || method == :patch || method == :put
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
8
|
+
begin
|
9
|
+
request_body = options[:body].nil? ? '' : options[:body]
|
10
|
+
request_body = request_body.to_json if options[:body].is_a?(Hash)
|
11
|
+
RestClient.send(method, get_url(url), request_body, headers)
|
12
|
+
rescue RestClient::Exception => e
|
13
|
+
e.response
|
14
|
+
end
|
15
|
+
else
|
16
|
+
begin
|
17
|
+
RestClient.send(method, get_url(url), headers)
|
18
|
+
rescue RestClient::Exception => e
|
19
|
+
e.response
|
20
|
+
end
|
21
|
+
end
|
24
22
|
res
|
25
23
|
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def base_headers
|
28
|
+
{ content_type: :json }.merge(Airborne.configuration.headers || {})
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'client requester' do
|
4
|
+
before do
|
5
|
+
allow(RestClient).to receive(:send)
|
6
|
+
RSpec::Mocks.space.proxy_for(self).remove_stub_if_present(:get)
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
allow(RestClient).to receive(:send).and_call_original
|
11
|
+
Airborne.configure { |config| config.headers = {} }
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should set :content_type to :json by default' do
|
15
|
+
get '/foo'
|
16
|
+
|
17
|
+
expect(RestClient).to have_received(:send)
|
18
|
+
.with(:get, 'http://www.example.com/foo', { content_type: :json })
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should override headers with option[:headers]' do
|
22
|
+
get '/foo', { content_type: 'application/x-www-form-urlencoded' }
|
23
|
+
|
24
|
+
expect(RestClient).to have_received(:send)
|
25
|
+
.with(:get, 'http://www.example.com/foo', { content_type: 'application/x-www-form-urlencoded' })
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should override headers with airborne config headers' do
|
29
|
+
Airborne.configure { |config| config.headers = { content_type: 'text/plain' } }
|
30
|
+
|
31
|
+
get '/foo'
|
32
|
+
|
33
|
+
expect(RestClient).to have_received(:send)
|
34
|
+
.with(:get, 'http://www.example.com/foo', { content_type: 'text/plain' })
|
35
|
+
end
|
36
|
+
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.3
|
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:
|
12
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/airborne/request_expectations.rb
|
124
124
|
- lib/airborne/rest_client_requester.rb
|
125
125
|
- spec/airborne/base_spec.rb
|
126
|
+
- spec/airborne/client_requester_spec.rb
|
126
127
|
- spec/airborne/delete_spec.rb
|
127
128
|
- spec/airborne/expectations/expect_header_contains_spec.rb
|
128
129
|
- spec/airborne/expectations/expect_header_spec.rb
|
@@ -189,8 +190,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
190
|
version: '0'
|
190
191
|
requirements: []
|
191
192
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.4.
|
193
|
+
rubygems_version: 2.4.5.1
|
193
194
|
signing_key:
|
194
195
|
specification_version: 4
|
195
196
|
summary: RSpec driven API testing framework
|
196
197
|
test_files: []
|
198
|
+
has_rdoc:
|