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: 5f7b084698d4c47d604863ccbfe4c36b1d5d7815e0b9b011ae1d2f83c8a61895
4
- data.tar.gz: 00be9619242873d469ce87df87f320e8bb2ce78f8316537f6015023b9c0ac304
3
+ metadata.gz: 6963885aed966be115cf500f834989d2f6255ef9aa349824d5a522d1c6721f6b
4
+ data.tar.gz: f110ac903b2df56537c8a4a8ece422f36150568258c9a1d1e60de23846c99d8e
5
5
  SHA512:
6
- metadata.gz: ad4a4d532cf894994470e285584ecf54a024591dc7adc43d32cd63aaf32d9bcb7ae4720a96b759b5df8baf38798aa9896332848a0f9dee769f3fa65b6e88c4a5
7
- data.tar.gz: '099e654bb588b941b5becb906a4b75a7f5c97ce261ed2be093683ee9a39ff9df31ef205252180c72a532b32464d28aa38b59f8e6aeb13a4f79bc00ec9a3790b8'
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
- # returns Yao::Resources::*
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
@@ -10,14 +10,6 @@ module Yao::Resources
10
10
  self.admin = true
11
11
 
12
12
  class << self
13
- def find_by_name(name, query={})
14
- if api_verion_v2?
15
- [super]
16
- else
17
- super
18
- end
19
- end
20
-
21
13
  def return_single_on_querying
22
14
  api_verion_v2?
23
15
  end
@@ -1,3 +1,3 @@
1
1
  module Yao
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
@@ -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") { [Struct.new(:id).new(uuid)] }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yao
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uchio, KONDO