airborne 0.2.2 → 0.2.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f1bb8d459481fbacaafd1d72b5849e435ca611c
4
- data.tar.gz: 2454e521d94443aaae41290fdd798560e14f808c
3
+ metadata.gz: c6f55b477b3b74d9872eb367610d368fb6b987b4
4
+ data.tar.gz: e6b5489646213522e340f9f3d0e314535dd8ef15
5
5
  SHA512:
6
- metadata.gz: 24a08e05af16617fc9a5cc5d5e11fec8c512d8571281ba162e42ed9834e6307a3611ee3018a1f9a7e270764a89dd8649bdf69124b4ea2d3ce0db175942515dc0
7
- data.tar.gz: 2f48afa8c36161e387d9800a114e6effc8aa1a9d52b78fb1afb704dddaa4d52e95567cd11c67a726f26ecce8673e75a355a621e0c1b386bb88f3e41b2b132e16
6
+ metadata.gz: 127e91334701c8b69e7bdbe8430b19c903708e608147f7c67c9a9e127d8b0757d7f9fa786497ccfc3ca789b4486f061333a9490cf6a3fe82e58ffd95ef6469d5
7
+ data.tar.gz: 89693d8b556bdd84127685789ee3d38da29bc4b209f08faf4ea0e32faa482b5616730f24e8bab9f6389916dd1beec20e2f687714bb795a8245319a987eb17df5
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'airborne'
3
- s.version = '0.2.2'
3
+ s.version = '0.2.3'
4
4
  s.date = Date.today.to_s
5
5
  s.summary = 'RSpec driven API testing framework'
6
6
  s.authors = ['Alex Friedman', 'Seth Pollack']
@@ -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 = { content_type: :json }.merge(options[: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
- begin
11
- request_body = options[:body].nil? ? '' : options[:body]
12
- request_body = request_body.to_json if options[:body].is_a?(Hash)
13
- RestClient.send(method, get_url(url), request_body, headers)
14
- rescue RestClient::Exception => e
15
- e.response
16
- end
17
- else
18
- begin
19
- RestClient.send(method, get_url(url), headers)
20
- rescue RestClient::Exception => e
21
- e.response
22
- end
23
- end
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.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: 2015-12-16 00:00:00.000000000 Z
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.3
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: