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 +4 -4
- data/README.md +5 -2
- data/lib/xsr/response.rb +2 -4
- data/test/response_test.rb +24 -24
- data/xsr.gemspec +1 -1
- 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: 174dc7e4fd5f56ecbebf9403d7322716cb33201f
|
4
|
+
data.tar.gz: c0c1fbb19e00f5c746187c127706ce6b95eb846d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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
data/test/response_test.rb
CHANGED
@@ -7,51 +7,51 @@ module ResponseTest
|
|
7
7
|
end
|
8
8
|
|
9
9
|
test "status 200 is a successful response" do
|
10
|
-
|
11
|
-
assert
|
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
|
-
|
16
|
-
assert
|
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
|
-
|
21
|
-
assert
|
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
|
-
|
26
|
-
assert !
|
27
|
-
assert
|
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
|
-
|
32
|
-
assert !
|
33
|
-
assert
|
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
|
-
|
38
|
-
assert !
|
39
|
-
assert
|
37
|
+
res = @client.get('/status/500')
|
38
|
+
assert !res.success?
|
39
|
+
assert res.server_error?
|
40
40
|
end
|
41
41
|
|
42
|
-
test "simple
|
42
|
+
test "simple json response" do
|
43
43
|
req = {some_attrib: 'some_value'}
|
44
|
-
|
44
|
+
res = @client.post('/post', body: req)
|
45
45
|
|
46
|
-
assert
|
47
|
-
assert_equal
|
46
|
+
assert res.success?
|
47
|
+
assert_equal res.body[:json], req
|
48
48
|
end
|
49
49
|
|
50
|
-
test "
|
50
|
+
test "json response with nested attributes" do
|
51
51
|
req = {something: {some_attrib: 'some_value'}}
|
52
|
-
|
52
|
+
res = @client.post('/post', body: req)
|
53
53
|
|
54
|
-
assert
|
55
|
-
assert_equal
|
54
|
+
assert res.success?
|
55
|
+
assert_equal res.body[:json], req
|
56
56
|
end
|
57
|
-
end
|
57
|
+
end
|
data/xsr.gemspec
CHANGED