xsr 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6cf6e749a891f90946693ebdc414de76435b637f
4
- data.tar.gz: 2ebfeaaf41d880091a2da266a8164ec80d16f651
3
+ metadata.gz: 174dc7e4fd5f56ecbebf9403d7322716cb33201f
4
+ data.tar.gz: c0c1fbb19e00f5c746187c127706ce6b95eb846d
5
5
  SHA512:
6
- metadata.gz: 70a4ca9819b95bb487b0e06e53ccb2e77e07efd7a9a91141e0567b93d7550170a42cdda1df57b9d468399c7cad5b4b22615546c2fce4119dc648c32d9bf8d561
7
- data.tar.gz: b8248262f4ec38938af1a1f1313f4dd201bc925cf2a3865e1f9d1fa07e564c5915e6dde6498c65d6e5e063c4885f2e836f2b0d59183f8fbc55ebc34422dbd57b
6
+ metadata.gz: fa07c616864c1edaa29419bfa0b2fe8d35fa3bb44d1392f716cf6a44364e90e0e5b0894ff4b3a6c9d820e546dca2e053b1ee775d2a10e179c6ae2b3fad63ef8f
7
+ data.tar.gz: 695e3f98d09f887908a1e84c7916ec5dbdc276b5f4b171d88007cba1269fc9c799cd7999cbed24d1522aeebd532d0fb90717fa040a92d19464bb7e0ca600bca8
data/README.md CHANGED
@@ -43,7 +43,7 @@ And then invoke a service:
43
43
  resp = client.get('http://api.something.io')
44
44
  resp.success?
45
45
  #=> true
46
- resp.body
46
+ resp.json_body
47
47
  #=> JSON response as a Ruby Hash Object
48
48
  ```
49
49
  ###Supported HTTP verbs
@@ -104,8 +104,11 @@ resp.not_found?
104
104
  resp.server_error?
105
105
  #=> Response status code is 500
106
106
 
107
- resp.body
107
+ resp.json_body
108
108
  #=> JSON response as a Ruby Hash object
109
+
110
+ resp.body
111
+ #-> plain HTTP response string
109
112
  ```
110
113
 
111
114
  ##What's next?
data/lib/xsr/response.rb CHANGED
@@ -23,9 +23,7 @@ module XSR
23
23
  end
24
24
 
25
25
  def body
26
- if self.success?
27
- @http_response.body && MultiJson.load( @http_response.body, symbolize_keys: true )
28
- end
26
+ MultiJson.load @http_response.body, symbolize_keys: true
29
27
  end
30
28
  end
31
- end
29
+ end
@@ -7,51 +7,51 @@ module ResponseTest
7
7
  end
8
8
 
9
9
  test "status 200 is a successful response" do
10
- resp = @client.get('/status/200')
11
- assert resp.success?
10
+ res = @client.get('/status/200')
11
+ assert res.success?
12
12
  end
13
13
 
14
14
  test "status 201 is a successful response" do
15
- resp = @client.get('/status/201')
16
- assert resp.success?
15
+ res = @client.get('/status/201')
16
+ assert res.success?
17
17
  end
18
18
 
19
19
  test "status 202 is a successful response" do
20
- resp = @client.get('/status/202')
21
- assert resp.success?
20
+ res = @client.get('/status/202')
21
+ assert res.success?
22
22
  end
23
23
 
24
24
  test "status 400 is a successful response" do
25
- resp = @client.get('/status/400')
26
- assert !resp.success?
27
- assert resp.bad_request?
25
+ res = @client.get('/status/400')
26
+ assert !res.success?
27
+ assert res.bad_request?
28
28
  end
29
29
 
30
30
  test "status 404 is a successful response" do
31
- resp = @client.get('/status/404')
32
- assert !resp.success?
33
- assert resp.not_found?
31
+ res = @client.get('/status/404')
32
+ assert !res.success?
33
+ assert res.not_found?
34
34
  end
35
35
 
36
36
  test "status 500 is a successful response" do
37
- resp = @client.get('/status/500')
38
- assert !resp.success?
39
- assert resp.server_error?
37
+ res = @client.get('/status/500')
38
+ assert !res.success?
39
+ assert res.server_error?
40
40
  end
41
41
 
42
- test "simple body" do
42
+ test "simple json response" do
43
43
  req = {some_attrib: 'some_value'}
44
- resp = @client.post('/post', body: req)
44
+ res = @client.post('/post', body: req)
45
45
 
46
- assert resp.success?
47
- assert_equal resp.body[:json], req
46
+ assert res.success?
47
+ assert_equal res.body[:json], req
48
48
  end
49
49
 
50
- test "body with nested attributes" do
50
+ test "json response with nested attributes" do
51
51
  req = {something: {some_attrib: 'some_value'}}
52
- resp = @client.post('/post', body: req)
52
+ res = @client.post('/post', body: req)
53
53
 
54
- assert resp.success?
55
- assert_equal resp.body[:json], req
54
+ assert res.success?
55
+ assert_equal res.body[:json], req
56
56
  end
57
- end
57
+ end
data/xsr.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'xsr'
3
- s.version = '1.1.0'
3
+ s.version = '1.2.0'
4
4
  s.summary = "XSR: eXtremely Simple REST Client"
5
5
  s.description = "A very simple library to talk to a REST/JSON API"
6
6
  s.authors = ["Matias Owsianik"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xsr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Owsianik