yao 0.9.0 → 0.9.1
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6963885aed966be115cf500f834989d2f6255ef9aa349824d5a522d1c6721f6b
|
4
|
+
data.tar.gz: f110ac903b2df56537c8a4a8ece422f36150568258c9a1d1e60de23846c99d8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bef23cbc43e2f274a11b87eafc5c3fc8e7e549bf2624a63bf27158a5f1cef633fb8f911bbfcdb2e2003dd1c0031d750259b8e6e95178c3b614cecc57ae0e91f
|
7
|
+
data.tar.gz: 202374e5a06cee6eb569f0b7d87f1164fd38bcfbf4fef7165c958798e3ea4534341901b6fd11f31b84c0efc58cdef4a35bfec9a91c14fda23ebb715c59ec6c58
|
@@ -88,10 +88,8 @@ module Yao::Resources
|
|
88
88
|
|
89
89
|
json = GET(url, query).body
|
90
90
|
if return_single_on_querying && !query.empty?
|
91
|
-
|
92
|
-
resource_from_json(json)
|
91
|
+
[resource_from_json(json)]
|
93
92
|
else
|
94
|
-
# returns Array of Yao::Resources::*
|
95
93
|
resources_from_json(json)
|
96
94
|
end
|
97
95
|
end
|
data/lib/yao/resources/user.rb
CHANGED
data/lib/yao/version.rb
CHANGED
@@ -9,6 +9,17 @@ module RestfullAccessibleStub
|
|
9
9
|
)
|
10
10
|
end
|
11
11
|
|
12
|
+
def stub_get_request_with_json_response(url, body)
|
13
|
+
stub_request(:get, url)
|
14
|
+
.with(
|
15
|
+
headers: request_headers
|
16
|
+
).to_return(
|
17
|
+
status: 200,
|
18
|
+
headers: {'Content-Type' => 'application/json'},
|
19
|
+
body: body.to_json
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
12
23
|
def stub_get_request_not_found(url)
|
13
24
|
stub_request(:get, url)
|
14
25
|
.with(
|
@@ -38,19 +38,34 @@ class TestRestfullyAccesible < Test::Unit::TestCase
|
|
38
38
|
assert_equal("OK", Test.get(id))
|
39
39
|
end
|
40
40
|
|
41
|
-
test 'name' do
|
41
|
+
test 'name (return_single_on_querying = true)' do
|
42
42
|
Test.return_single_on_querying = true
|
43
43
|
name = "dummy"
|
44
44
|
uuid = "00112233-4455-6677-8899-aabbccddeeff"
|
45
45
|
|
46
46
|
stub_get_request_not_found([@url, @resources_name, name].join('/'))
|
47
47
|
stub_get_request([@url, "#{@resources_name}?name=dummy"].join('/'), @resources_name)
|
48
|
-
mock(Test).new("dummy_resource") {
|
48
|
+
mock(Test).new("dummy_resource") { Struct.new(:id).new(uuid) }
|
49
49
|
stub_get_request([@url, @resources_name, uuid].join('/'), @resources_name)
|
50
50
|
mock(Test).new("dummy_resource") { "OK" }
|
51
51
|
|
52
52
|
assert_equal("OK", Test.get(name))
|
53
53
|
end
|
54
|
+
|
55
|
+
test 'name' do
|
56
|
+
Test.return_single_on_querying = false
|
57
|
+
name = "dummy"
|
58
|
+
uuid = "00112233-4455-6677-8899-aabbccddeeff"
|
59
|
+
body = {@resources_name => [@resources_name]}
|
60
|
+
|
61
|
+
stub_get_request_not_found([@url, @resources_name, name].join('/'))
|
62
|
+
stub_get_request_with_json_response([@url, "#{@resources_name}?name=dummy"].join('/'), body)
|
63
|
+
mock(Test).new("dummy_resources") { Struct.new(:id).new(uuid) }
|
64
|
+
stub_get_request([@url, @resources_name, uuid].join('/'), @resource_name)
|
65
|
+
mock(Test).new("dummy_resource") { "OK" }
|
66
|
+
|
67
|
+
assert_equal("OK", Test.get(name))
|
68
|
+
end
|
54
69
|
end
|
55
70
|
|
56
71
|
sub_test_case 'get!' do
|