apipie-bindings 0.0.7 → 0.0.8

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: 9fbf9178dc6e7698d91a6a0d9f57bb3ca00e6b40
4
- data.tar.gz: 7ede66362f69586d304590dd6c449bc4fe5e5f26
3
+ metadata.gz: 599291a9b42deb0d3ddd3a6f796b457f3a68e130
4
+ data.tar.gz: 09647fa549f97f8f9ad33752ef03575623d79c9c
5
5
  SHA512:
6
- metadata.gz: 25ba2db8f6dcae59ca171a0309fccca7a1bfb8978dfac0a860d62a5c33e4f62c65cbedd6c0b98d6d79da37196fd10beefb941d69ee26860a6dd9e50fd85008ed
7
- data.tar.gz: 11194189f412fc4627b2d61abd9472f2a2543c56889c27c99d6c2dc91a92840f1bcfe4789c0f79e117cf4825bc01aba11ca721d47a06895fa7975979f23e78d4
6
+ metadata.gz: 584534611a2c0abc81f8fee5bf9ba4b2732f297daa70109ed006537e134d9e450f69cdf12d2f21982f6125bb6205d7351fc4fb720f2f2c789ec7231fb52c2265
7
+ data.tar.gz: 24e2128d38775d801394ea84be5aaeb0bdfc7bcd312c76484e1ef0c6aaf8a950214a6400a918e999eef9e6716bea53faec63e74fdd86277708d6a46dac04d4cc
@@ -295,11 +295,10 @@ module ApipieBindings
295
295
 
296
296
  def process_data(response)
297
297
  data = begin
298
- JSON.parse(response.body)
298
+ JSON.parse((response.respond_to?(:body) ? response.body : response) || '')
299
299
  rescue JSON::ParserError
300
- response.body
300
+ response.respond_to?(:body) ? response.body : response || ''
301
301
  end
302
- # logger.debug "Returned data: #{data.inspect}"
303
302
  return data
304
303
  end
305
304
  end
@@ -1,5 +1,5 @@
1
1
  module ApipieBindings
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.0.7'
3
+ @version ||= Gem::Version.new '0.0.8'
4
4
  end
5
5
  end
@@ -70,6 +70,22 @@ describe ApipieBindings::API do
70
70
  result = api.http_call(:post, '/api/path', {:file => s}, headers, {:response => :raw})
71
71
  end
72
72
 
73
+ it "should process nil response safely" do
74
+ api.send(:process_data, nil).must_equal ''
75
+ end
76
+
77
+ it "should process empty response safely" do
78
+ api.send(:process_data, '').must_equal ''
79
+ end
80
+
81
+ it "should process empty JSON response safely" do
82
+ api.send(:process_data, '{}').must_equal({})
83
+ end
84
+
85
+ it "should process JSON response safely" do
86
+ api.send(:process_data, '{"a" : []}').must_equal({'a' => []})
87
+ end
88
+
73
89
  context "update_cache" do
74
90
 
75
91
  before :each do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apipie-bindings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Bačovský