airborne 0.3.5 → 0.3.6
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 +4 -4
- data/airborne.gemspec +1 -1
- data/lib/airborne/rest_client_requester.rb +8 -2
- data/spec/airborne/post_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff10527022f91760eebf46755e829ee2d0253229bccc1c1266c0913d9357fec5
|
4
|
+
data.tar.gz: ca9ef3d342550dcd6f160ec5c21982ea9002a6985b2851cb9859fd3e276e408c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc0d7fe0a30a8d803733f0e3ecd519a4bd09d4b0469f4bc2b2f806e1390021efad3338e516c2c75ad3dc8788dc65a1e497a1db57759f6f7d50e98a27cd556552
|
7
|
+
data.tar.gz: 1ac158dafa41fa4b2435d018919c7b45938b9fc21c8082da95e7a76186d2822e366139210d1e7b7d0f4fddb22e5c2e290a1bfb1d5b0335ef9297ae22568574f3
|
data/airborne.gemspec
CHANGED
@@ -7,8 +7,8 @@ module Airborne
|
|
7
7
|
verify_ssl = options.fetch(:verify_ssl, true)
|
8
8
|
res = if method == :post || method == :patch || method == :put || method == :delete
|
9
9
|
begin
|
10
|
-
request_body = options[:body].nil? || options[:body]
|
11
|
-
request_body = request_body.to_json if is_json_request(headers) && !request_body
|
10
|
+
request_body = options[:body].nil? || is_empty(options[:body]) ? '' : options[:body]
|
11
|
+
request_body = request_body.to_json if is_json_request(headers) && !is_empty(request_body)
|
12
12
|
RestClient::Request.execute(
|
13
13
|
method: method,
|
14
14
|
url: get_url(url),
|
@@ -41,6 +41,12 @@ module Airborne
|
|
41
41
|
header == :json || /application\/([a-zA-Z0-9\.\_\-]*\+?)json/ =~ header
|
42
42
|
end
|
43
43
|
|
44
|
+
def is_empty(body)
|
45
|
+
return body.empty? if body.respond_to?(:empty?)
|
46
|
+
|
47
|
+
false
|
48
|
+
end
|
49
|
+
|
44
50
|
def base_headers
|
45
51
|
{ content_type: :json }.merge(Airborne.configuration.headers || {})
|
46
52
|
end
|
data/spec/airborne/post_spec.rb
CHANGED
@@ -14,4 +14,11 @@ describe 'post' do
|
|
14
14
|
post '/simple_post', 'hello', content_type: 'text/plain'
|
15
15
|
expect(WebMock).to have_requested(:post, url).with(body: 'hello', headers: { 'Content-Type' => 'text/plain' })
|
16
16
|
end
|
17
|
+
|
18
|
+
it 'should allow testing on post requests with IO body' do
|
19
|
+
url = 'http://www.example.com/simple_post'
|
20
|
+
stub_request(:post, url)
|
21
|
+
post '/simple_post', StringIO.new('hello'), content_type: 'application/octet-stream'
|
22
|
+
expect(WebMock).to have_requested(:post, url).with(body: 'hello', headers: { 'Content-Type' => 'application/octet-stream' })
|
23
|
+
end
|
17
24
|
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.3.
|
4
|
+
version: 0.3.6
|
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: 2020-
|
12
|
+
date: 2020-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|