rest_client_plus 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/do_something_response.json +0 -0
- data/lib/requests.rb +1 -5
- data/rest_client_plus.gemspec +1 -1
- data/tests/rest_client_plus_test.rb +4 -0
- data/tests/webservice_stubs/stubs.rb +6 -1
- metadata +2 -1
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -39,7 +39,7 @@ Require using:
|
|
39
39
|
|
40
40
|
RestClientPlus provides GET, POST and PUT methods which return a Ruby hash if json is received.
|
41
41
|
|
42
|
-
ArrayHelper.unwrap_from_array
|
42
|
+
ArrayHelper.unwrap_from_array will unwrap a hash from a single-element array. Array is also extended as
|
43
43
|
Array#unwrap_from_array so:
|
44
44
|
|
45
45
|
[ {:key => "value"} ].unwrap_from_array! #=> {:key => "value"}
|
File without changes
|
data/lib/requests.rb
CHANGED
@@ -14,12 +14,8 @@ module RestClientPlus
|
|
14
14
|
parse_response(RestClient.get(input_url))
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
17
|
def self.parse_response(response)
|
21
|
-
|
22
|
-
response.body
|
18
|
+
response.respond_to?(:reverse) ? JSON.parse(response) : response
|
23
19
|
end
|
24
20
|
|
25
21
|
end
|
data/rest_client_plus.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "rest_client_plus"
|
7
|
-
s.version = "0.0.
|
7
|
+
s.version = "0.0.6"
|
8
8
|
s.authors = ["John Wakeling", "Darren Bown"]
|
9
9
|
s.email = ["jwakeling23@gmail.com", "darren.bown@droidqa.co.uk"]
|
10
10
|
s.description = %q{Extensions to Ruby's RestClient}
|
@@ -25,5 +25,9 @@ class RestClientPlusTest < Test::Unit::TestCase
|
|
25
25
|
assert_respond_to(RestClientPlus::Requests.put_json_to_url('http://www.mocks.stub', {:body => "body"}), :each_key)
|
26
26
|
end
|
27
27
|
|
28
|
+
def test_parse_response
|
29
|
+
assert_respond_to(RestClientPlus::Requests.parse_response({:body =>{:one => "1", :two => "2"}}.to_json), :each_key)
|
30
|
+
end
|
31
|
+
|
28
32
|
|
29
33
|
end
|
@@ -6,7 +6,12 @@ module WSStubs
|
|
6
6
|
|
7
7
|
WebMock::API.stub_request(:get, "www.mocks.stub").to_return(RETURN_BODY)
|
8
8
|
|
9
|
-
WebMock::API.stub_request(:
|
9
|
+
WebMock::API.stub_request(:post, "http://www.mocks.stub/").
|
10
|
+
with(:body => REQUEST_BODY,
|
11
|
+
:request_headers => REQUEST_HEADERS).
|
12
|
+
to_return(RETURN_OBJECT)
|
13
|
+
|
14
|
+
WebMock::API.stub_request(:put, "http://www.mocks.stub/").
|
10
15
|
with(:body => REQUEST_BODY,
|
11
16
|
:request_headers => REQUEST_HEADERS).
|
12
17
|
to_return(RETURN_OBJECT)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest_client_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- LICENSE
|
59
59
|
- README.md
|
60
60
|
- Rakefile
|
61
|
+
- do_something_response.json
|
61
62
|
- lib/array_helper.rb
|
62
63
|
- lib/requests.rb
|
63
64
|
- lib/rest_client_plus.rb
|