apipie-bindings 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/apipie_bindings/api.rb +2 -3
- data/lib/apipie_bindings/version.rb +1 -1
- data/test/unit/api_test.rb +16 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 599291a9b42deb0d3ddd3a6f796b457f3a68e130
|
4
|
+
data.tar.gz: 09647fa549f97f8f9ad33752ef03575623d79c9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 584534611a2c0abc81f8fee5bf9ba4b2732f297daa70109ed006537e134d9e450f69cdf12d2f21982f6125bb6205d7351fc4fb720f2f2c789ec7231fb52c2265
|
7
|
+
data.tar.gz: 24e2128d38775d801394ea84be5aaeb0bdfc7bcd312c76484e1ef0c6aaf8a950214a6400a918e999eef9e6716bea53faec63e74fdd86277708d6a46dac04d4cc
|
data/lib/apipie_bindings/api.rb
CHANGED
@@ -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
|
data/test/unit/api_test.rb
CHANGED
@@ -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
|