mushikago-sdk 0.2.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -6
- data/autotest/discover.rb +1 -0
- data/doc/Mushikago.html +37 -21
- data/doc/Mushikago/Auth.html +8 -4
- data/doc/Mushikago/Auth/Signature.html +59 -32
- data/doc/Mushikago/Auth/Signer.html +81 -44
- data/doc/Mushikago/Config.html +41 -18
- data/doc/Mushikago/Hotaru.html +120 -0
- data/doc/Mushikago/Hotaru/Client.html +818 -0
- data/doc/Mushikago/Hotaru/Request.html +303 -0
- data/doc/Mushikago/Http.html +10 -6
- data/doc/Mushikago/Http/Client.html +107 -58
- data/doc/Mushikago/Http/MultipartRequest.html +366 -0
- data/doc/Mushikago/Http/Request.html +289 -167
- data/doc/Mushikago/Http/Response.html +153 -70
- data/doc/Mushikago/Mitsubachi.html +108 -0
- data/doc/Mushikago/Mitsubachi/Client.html +2923 -0
- data/doc/Mushikago/Mitsubachi/HttpFetchRequest.html +363 -0
- data/doc/Mushikago/Mitsubachi/HttpPushRequest.html +365 -0
- data/doc/Mushikago/Mitsubachi/MultipartRequest.html +332 -0
- data/doc/Mushikago/Mitsubachi/ProjectCreateRequest.html +361 -0
- data/doc/Mushikago/Mitsubachi/ProjectDeleteRequest.html +351 -0
- data/doc/Mushikago/Mitsubachi/ProjectDiscontinueRequest.html +349 -0
- data/doc/Mushikago/Mitsubachi/ProjectInfoRequest.html +302 -0
- data/doc/Mushikago/Mitsubachi/ProjectListRequest.html +304 -0
- data/doc/Mushikago/Mitsubachi/ProjectQueuesRequest.html +300 -0
- data/doc/Mushikago/Mitsubachi/ProjectUpdateRequest.html +359 -0
- data/doc/Mushikago/Mitsubachi/Request.html +307 -0
- data/doc/Mushikago/Mitsubachi/ResourceDeleteRequest.html +351 -0
- data/doc/Mushikago/Mitsubachi/ResourceGetRequest.html +302 -0
- data/doc/Mushikago/Mitsubachi/ResourceListRequest.html +306 -0
- data/doc/Mushikago/Mitsubachi/ResourceStoreRequest.html +390 -0
- data/doc/Mushikago/Mitsubachi/ScriptDeleteRequest.html +351 -0
- data/doc/Mushikago/Mitsubachi/ScriptDeployRequest.html +386 -0
- data/doc/Mushikago/Mitsubachi/ScriptGetRequest.html +302 -0
- data/doc/Mushikago/Mitsubachi/ScriptListRequest.html +306 -0
- data/doc/Mushikago/Tombo.html +8 -4
- data/doc/Mushikago/Tombo/CaptureRequest.html +90 -34
- data/doc/Mushikago/Tombo/CapturesRequest.html +68 -27
- data/doc/Mushikago/Tombo/Client.html +181 -75
- data/doc/Mushikago/Tombo/DeleteRequest.html +44 -24
- data/doc/Mushikago/Tombo/InfoRequest.html +32 -16
- data/doc/Mushikago/Tombo/Request.html +45 -15
- data/doc/_index.html +192 -9
- data/doc/class_list.html +1 -1
- data/doc/css/full_list.css +2 -0
- data/doc/css/style.css +12 -10
- data/doc/file.README.html +66 -60
- data/doc/frames.html +1 -1
- data/doc/index.html +66 -60
- data/doc/js/app.js +4 -4
- data/doc/js/full_list.js +23 -6
- data/doc/method_list.html +622 -62
- data/doc/top-level-namespace.html +3 -3
- data/lib/mushikago-sdk.rb +1 -0
- data/lib/mushikago.rb +3 -0
- data/lib/mushikago/auth.rb +1 -0
- data/lib/mushikago/auth/signature.rb +1 -0
- data/lib/mushikago/auth/signer.rb +1 -0
- data/lib/mushikago/configuration.rb +3 -2
- data/lib/mushikago/hotaru.rb +22 -0
- data/lib/mushikago/hotaru/client.rb +76 -0
- data/lib/mushikago/hotaru/request.rb +32 -0
- data/lib/mushikago/http.rb +2 -0
- data/lib/mushikago/http/client.rb +2 -1
- data/lib/mushikago/http/multipart_request.rb +62 -0
- data/lib/mushikago/http/request.rb +5 -2
- data/lib/mushikago/http/response.rb +1 -0
- data/lib/mushikago/mitsubachi.rb +33 -0
- data/lib/mushikago/mitsubachi/client.rb +256 -0
- data/lib/mushikago/mitsubachi/http_fetch_request.rb +33 -0
- data/lib/mushikago/mitsubachi/http_push_request.rb +36 -0
- data/lib/mushikago/mitsubachi/multipart_request.rb +33 -0
- data/lib/mushikago/mitsubachi/project_create_request.rb +32 -0
- data/lib/mushikago/mitsubachi/project_delete_request.rb +23 -0
- data/lib/mushikago/mitsubachi/project_discontinue_request.rb +22 -0
- data/lib/mushikago/mitsubachi/project_info_request.rb +17 -0
- data/lib/mushikago/mitsubachi/project_list_request.rb +21 -0
- data/lib/mushikago/mitsubachi/project_queues_request.rb +16 -0
- data/lib/mushikago/mitsubachi/project_update_request.rb +31 -0
- data/lib/mushikago/mitsubachi/request.rb +32 -0
- data/lib/mushikago/mitsubachi/resource_delete_request.rb +24 -0
- data/lib/mushikago/mitsubachi/resource_get_request.rb +19 -0
- data/lib/mushikago/mitsubachi/resource_list_request.rb +22 -0
- data/lib/mushikago/mitsubachi/resource_store_request.rb +33 -0
- data/lib/mushikago/mitsubachi/script_delete_request.rb +23 -0
- data/lib/mushikago/mitsubachi/script_deploy_request.rb +28 -0
- data/lib/mushikago/mitsubachi/script_get_request.rb +18 -0
- data/lib/mushikago/mitsubachi/script_list_request.rb +21 -0
- data/lib/mushikago/tombo.rb +1 -0
- data/lib/mushikago/tombo/capture_request.rb +2 -1
- data/lib/mushikago/tombo/captures_request.rb +2 -1
- data/lib/mushikago/tombo/client.rb +1 -0
- data/lib/mushikago/tombo/delete_request.rb +2 -1
- data/lib/mushikago/tombo/info_request.rb +2 -1
- data/lib/mushikago/tombo/request.rb +3 -2
- data/lib/mushikago/version.rb +2 -1
- data/spec/mushikago/auth/signature_spec.rb +1 -0
- data/spec/mushikago/auth/signer_spec.rb +1 -0
- data/spec/mushikago/configuration_spec.rb +7 -6
- data/spec/mushikago/http/client_spec.rb +3 -2
- data/spec/mushikago/http/request_spec.rb +3 -1
- data/spec/mushikago/http/response_spec.rb +1 -0
- data/spec/mushikago/tombo/capture_request_spec.rb +3 -2
- data/spec/mushikago/tombo/captures_request_spec.rb +3 -2
- data/spec/mushikago/tombo/client_spec.rb +91 -32
- data/spec/mushikago/tombo/delete_request_spec.rb +3 -2
- data/spec/mushikago/tombo/info_request_spec.rb +3 -2
- data/spec/mushikago/tombo/request_spec.rb +2 -1
- data/spec/spec_helper.rb +1 -0
- metadata +136 -115
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Mushikago
|
3
|
+
module Mitsubachi
|
4
|
+
class ScriptDeployRequest < MultipartRequest
|
5
|
+
def method_name; 'script/deploy' end
|
6
|
+
request_parameter :project_name
|
7
|
+
request_parameter :file
|
8
|
+
request_parameter :script_name
|
9
|
+
|
10
|
+
def initialize project_name, file_or_file_name, options={}
|
11
|
+
super(options)
|
12
|
+
self.project_name = project_name
|
13
|
+
if(file_or_file_name.kind_of?(File))
|
14
|
+
self.file = file_or_file_name
|
15
|
+
else
|
16
|
+
self.file = File.new(file_or_file_name.to_s)
|
17
|
+
end
|
18
|
+
self.script_name = options[:script_name] || file.path
|
19
|
+
end
|
20
|
+
|
21
|
+
def new_http_request
|
22
|
+
new_http_post_request(path)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Mushikago
|
3
|
+
module Mitsubachi
|
4
|
+
class ScriptGetRequest < Request
|
5
|
+
def method_name; 'script/get' end
|
6
|
+
request_parameter :project_name
|
7
|
+
request_parameter :script_name
|
8
|
+
|
9
|
+
def initialize project_name, script_name, options={}
|
10
|
+
super(options)
|
11
|
+
self.project_name = project_name
|
12
|
+
self.script_name = script_name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Mushikago
|
3
|
+
module Mitsubachi
|
4
|
+
class ScriptListRequest < Request
|
5
|
+
def method_name; 'script/list' end
|
6
|
+
request_parameter :project_name
|
7
|
+
request_parameter :limit do |v| v.to_i end
|
8
|
+
request_parameter :offset do |v| v.to_i end
|
9
|
+
request_parameter :filter
|
10
|
+
|
11
|
+
def initialize project_name, options={}
|
12
|
+
super(options)
|
13
|
+
self.project_name = project_name
|
14
|
+
self.limit = options[:limit] if options.has_key?(:limit)
|
15
|
+
self.offset = options[:offset] if options.has_key?(:offset)
|
16
|
+
self.filter = options[:filter] if options.has_key?(:filter)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
data/lib/mushikago/tombo.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
module Mushikago
|
2
3
|
module Tombo
|
3
4
|
# Tomboのリクエストを表す抽象クラス
|
@@ -8,11 +9,11 @@ module Mushikago
|
|
8
9
|
# @option options [String] :endpoint('tombo.mushikago.org') Tomboのエンドポイント
|
9
10
|
def initialize options={}
|
10
11
|
super()
|
11
|
-
endpoint = options[:endpoint] || Mushikago.config.
|
12
|
+
endpoint = options[:endpoint] || Mushikago.config.endpoint
|
12
13
|
host, port = endpoint.split(':')
|
13
14
|
@host = host
|
14
15
|
@port = port if port
|
15
|
-
@path = "/#{api_version}/#{method_name}"
|
16
|
+
@path = "/#{api_version}/tombo/#{method_name}"
|
16
17
|
end
|
17
18
|
|
18
19
|
# @private
|
data/lib/mushikago/version.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe Mushikago::Config do
|
@@ -18,7 +19,7 @@ describe Mushikago::Config do
|
|
18
19
|
subject{ Mushikago::Config.instance }
|
19
20
|
it{ should respond_to(:api_key) }
|
20
21
|
it{ should respond_to(:secret_key) }
|
21
|
-
it{ should respond_to(:
|
22
|
+
it{ should respond_to(:endpoint) }
|
22
23
|
end
|
23
24
|
|
24
25
|
# Mushikago::Configはデフォルトの値を持っている
|
@@ -26,7 +27,7 @@ describe Mushikago::Config do
|
|
26
27
|
subject{ Mushikago::Config.instance }
|
27
28
|
its(:api_key){ should == (ENV['MUSHIKAGO_API_KEY'] || ENV['MUSHIKAGO_API_KEY_ID']) }
|
28
29
|
its(:secret_key){ should == (ENV['MUSHIKAGO_SECRET_KEY'] || ENV['MUSHIKAGO_SECRET_ACCESS_KEY']) }
|
29
|
-
its(:
|
30
|
+
its(:endpoint){ should == 'api.mushikago.org' }
|
30
31
|
end
|
31
32
|
|
32
33
|
# Mushikago::Configは値をロードすることができる
|
@@ -35,14 +36,14 @@ describe Mushikago::Config do
|
|
35
36
|
Mushikago::Config.instance.load(
|
36
37
|
:api_key => 'api_key',
|
37
38
|
:secret_key => 'secret_key',
|
38
|
-
:
|
39
|
+
:endpoint => 'tombo.mushikago.org'
|
39
40
|
)
|
40
41
|
end
|
41
42
|
|
42
43
|
subject{ Mushikago::Config.instance }
|
43
44
|
its(:api_key){ should == 'api_key' }
|
44
45
|
its(:secret_key){ should == 'secret_key' }
|
45
|
-
its(:
|
46
|
+
its(:endpoint){ should == 'tombo.mushikago.org' }
|
46
47
|
|
47
48
|
# ロードする際のキーは文字列でもOK
|
48
49
|
context 'loading options key can be string' do
|
@@ -50,14 +51,14 @@ describe Mushikago::Config do
|
|
50
51
|
Mushikago::Config.instance.load(
|
51
52
|
'api_key' => 'api_key',
|
52
53
|
'secret_key' => 'secret_key',
|
53
|
-
'
|
54
|
+
'endpoint' => 'tombo.mushikago.org'
|
54
55
|
)
|
55
56
|
end
|
56
57
|
|
57
58
|
subject{ Mushikago::Config.instance }
|
58
59
|
its(:api_key){ should == 'api_key' }
|
59
60
|
its(:secret_key){ should == 'secret_key' }
|
60
|
-
its(:
|
61
|
+
its(:endpoint){ should == 'tombo.mushikago.org' }
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
class TestRequest < Mushikago::Http::Request
|
@@ -31,8 +32,8 @@ describe Mushikago::Http::Client do
|
|
31
32
|
context 'send test request' do
|
32
33
|
before :all do
|
33
34
|
request = TestRequest.new
|
34
|
-
request.host = '
|
35
|
-
request.path = '/1/info
|
35
|
+
request.host = 'api.mushikago.org'
|
36
|
+
request.path = '/1/tombo/info'
|
36
37
|
client = Mushikago::Http::Client.new
|
37
38
|
@response = client.send_request(request)
|
38
39
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
class SampleRequest < Mushikago::Http::Request
|
@@ -33,7 +34,7 @@ describe Mushikago::Http::Request do
|
|
33
34
|
its('port.to_i'){ should == 80 }
|
34
35
|
its(:path){ should == '/1/list.json' }
|
35
36
|
its(:headers){ should be_a_kind_of(Hash) }
|
36
|
-
it
|
37
|
+
it 'header["hoge"] should "fuga"' do subject.headers['hoge'].should == 'fuga' end
|
37
38
|
its(['param1']){ should == 'p1' }
|
38
39
|
its(['param2']){ should == 'p2' }
|
39
40
|
its(['timestamp']){ should == '2011-09-01T00:00:00Z' }
|
@@ -57,6 +58,7 @@ describe Mushikago::Http::Request do
|
|
57
58
|
|
58
59
|
it{ should respond_to(:sample1, :sample1=) }
|
59
60
|
it{ should respond_to(:sample2, :sample2=) }
|
61
|
+
it{ should respond_to(:sample3, :sample3=) }
|
60
62
|
|
61
63
|
its(:sample1){ should == 'hoge' }
|
62
64
|
its(:sample2){ should == 20 }
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe Mushikago::Tombo::CaptureRequest do
|
@@ -29,9 +30,9 @@ describe Mushikago::Tombo::CaptureRequest do
|
|
29
30
|
|
30
31
|
subject{ @request }
|
31
32
|
|
32
|
-
its(:host){ should == Mushikago.config.
|
33
|
+
its(:host){ should == Mushikago.config.endpoint }
|
33
34
|
its(:http_method){ should == 'POST' }
|
34
|
-
its(:path){ should == '/1/capture
|
35
|
+
its(:path){ should == '/1/tombo/capture' }
|
35
36
|
its(:url){ should == 'http://www.mushikago.org/' }
|
36
37
|
its(:image_format){ should == 'png' }
|
37
38
|
its(:image_quality){ should == '20' }
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe Mushikago::Tombo::CapturesRequest do
|
@@ -27,9 +28,9 @@ describe Mushikago::Tombo::CapturesRequest do
|
|
27
28
|
|
28
29
|
subject{ @request }
|
29
30
|
|
30
|
-
its(:host){ should == Mushikago.config.
|
31
|
+
its(:host){ should == Mushikago.config.endpoint }
|
31
32
|
its(:http_method){ should == 'GET' }
|
32
|
-
its(:path){ should == '/1/captures
|
33
|
+
its(:path){ should == '/1/tombo/captures' }
|
33
34
|
its(:id){ should == 'id' }
|
34
35
|
its(:limit){ should == '2' }
|
35
36
|
its(:offset){ should == '5' }
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe Mushikago::Tombo::Client do
|
@@ -14,72 +15,130 @@ describe Mushikago::Tombo::Client do
|
|
14
15
|
it{ should respond_to(:captures) }
|
15
16
|
it{ should respond_to(:delete) }
|
16
17
|
it{ should respond_to(:info) }
|
17
|
-
|
18
|
-
|
18
|
+
|
19
|
+
share_examples_for 'Basic response of request' do
|
20
|
+
it{ should be_a_kind_of(Mushikago::Http::Response) }
|
21
|
+
its(:meta){ should_not be_nil }
|
22
|
+
it 'meta status should 200' do subject.meta['status'].should == 200 end
|
23
|
+
it 'meta message should "OK"' do subject.meta['message'].should == 'OK' end
|
24
|
+
its(:response){ should_not be_nil }
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_http_mock(body)
|
28
|
+
http = Net::HTTP.new('localhost')
|
29
|
+
http.should_receive(:request).and_return do |request|
|
30
|
+
response = Net::HTTPOK.new(nil, 200, nil)
|
31
|
+
response.stub!(:body).and_return(body)
|
32
|
+
response
|
33
|
+
end
|
34
|
+
Net::HTTP.should_receive(:new).and_return(http)
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'send capture request and get mock response' do
|
19
38
|
before :all do
|
39
|
+
response = {
|
40
|
+
:meta => {:status => 200, :message => 'OK'},
|
41
|
+
:response => {
|
42
|
+
:id => 'image_id',
|
43
|
+
:image_url => 'http://img.tombo.ne.jp/sample.jpg',
|
44
|
+
:thumbnail_url => 'http://img.tombo.ne.jp/t/sample.jpg'
|
45
|
+
}
|
46
|
+
}
|
47
|
+
create_http_mock(response.to_json)
|
20
48
|
@response = @client.capture('http://www.tombo.ne.jp/', :thumbnail=>1)
|
21
49
|
end
|
22
50
|
|
23
51
|
subject{ @response }
|
24
52
|
|
25
|
-
|
26
|
-
|
27
|
-
its(
|
28
|
-
its(['
|
29
|
-
its(['image_url']){ should_not be_nil }
|
30
|
-
its(['thumbnail_url']){ should_not be_nil }
|
53
|
+
it_should_behave_like 'Basic response of request'
|
54
|
+
its(['id']){ should == 'image_id'}
|
55
|
+
its(['image_url']){ should == 'http://img.tombo.ne.jp/sample.jpg' }
|
56
|
+
its(['thumbnail_url']){ should == 'http://img.tombo.ne.jp/t/sample.jpg' }
|
31
57
|
end
|
32
58
|
|
33
|
-
context 'send captures request' do
|
59
|
+
context 'send captures request and get mock response' do
|
34
60
|
before :all do
|
61
|
+
response = {
|
62
|
+
:meta => {:status => 200, :message => 'OK'},
|
63
|
+
:response => {
|
64
|
+
:total => 2,
|
65
|
+
:images => [
|
66
|
+
{
|
67
|
+
:image_id => 'image_id',
|
68
|
+
:image_url => 'http://img.tombo.ne.jp/sample.jpg',
|
69
|
+
:image_size => 300,
|
70
|
+
:source_url => 'http://tombo.mushikago.org/',
|
71
|
+
:image_format => 'jpg',
|
72
|
+
:image_quality => 80,
|
73
|
+
:state => 'requested',
|
74
|
+
:tags => ['tag1', 'tag2'],
|
75
|
+
},
|
76
|
+
{}
|
77
|
+
]
|
78
|
+
}
|
79
|
+
}
|
80
|
+
create_http_mock(response.to_json)
|
35
81
|
@response = @client.captures
|
36
82
|
end
|
37
83
|
|
38
84
|
subject{ @response }
|
39
|
-
|
40
|
-
|
41
|
-
its(
|
42
|
-
its(['total']){ should_not be_nil }
|
43
|
-
its(['images']){ should_not be_nil }
|
85
|
+
|
86
|
+
it_should_behave_like 'Basic response of request'
|
87
|
+
its(['total']){ should == 2 }
|
44
88
|
its(['images']){ should be_a_kind_of(Enumerable) }
|
45
|
-
|
89
|
+
its(['images']){ should have_exactly(2).items }
|
46
90
|
|
47
91
|
context 'returned images should have keys' do
|
48
92
|
subject{ @response['images'].first }
|
49
|
-
its(['image_id']){
|
50
|
-
its(['image_url']){
|
51
|
-
its(['image_size']){
|
52
|
-
its(['source_url']){
|
53
|
-
its(['image_format']){
|
54
|
-
its(['image_quality']){
|
55
|
-
its(['state']){
|
56
|
-
its(['tags']){ should_not be_nil }
|
93
|
+
its(['image_id']){ should == 'image_id' }
|
94
|
+
its(['image_url']){ should == 'http://img.tombo.ne.jp/sample.jpg' }
|
95
|
+
its(['image_size']){ should == 300 }
|
96
|
+
its(['source_url']){ should == 'http://tombo.mushikago.org/' }
|
97
|
+
its(['image_format']){ should == 'jpg' }
|
98
|
+
its(['image_quality']){ should == 80 }
|
99
|
+
its(['state']){ should == 'requested' }
|
57
100
|
its(['tags']){ should be_a_kind_of(Enumerable) }
|
101
|
+
its(['tags']){ should have_exactly(2).items }
|
58
102
|
end
|
59
103
|
end
|
60
104
|
|
61
|
-
context 'send delete request' do
|
105
|
+
context 'send delete request and get mock response' do
|
62
106
|
before :all do
|
63
|
-
|
107
|
+
response = {
|
108
|
+
:meta => {:status => 200, :message => 'OK'},
|
109
|
+
:response => {
|
110
|
+
:id => '391d7fe4-e9d4-4975-85a3-e5d38a4cd97f'
|
111
|
+
}
|
112
|
+
}
|
113
|
+
create_http_mock(response.to_json)
|
114
|
+
@response = @client.delete('s391d7fe4-e9d4-4975-85a3-e5d38a4cd97f')
|
64
115
|
end
|
65
116
|
|
66
117
|
subject{ @response }
|
67
118
|
|
68
|
-
|
69
|
-
its(['id']){ should_not be_nil }
|
119
|
+
it_should_behave_like 'Basic response of request'
|
70
120
|
its(['id']){ should == '391d7fe4-e9d4-4975-85a3-e5d38a4cd97f' }
|
71
121
|
end
|
72
122
|
|
73
|
-
context 'send info request' do
|
123
|
+
context 'send info request and get mock response' do
|
74
124
|
before :all do
|
125
|
+
response = {
|
126
|
+
:meta => {:status => 200, :message => 'OK'},
|
127
|
+
:response => {
|
128
|
+
:api_count => 500,
|
129
|
+
:disk_usage => 5500,
|
130
|
+
:image_num => 2,
|
131
|
+
}
|
132
|
+
}
|
133
|
+
create_http_mock(response.to_json)
|
75
134
|
@response = @client.info
|
76
135
|
end
|
77
136
|
|
78
137
|
subject{ @response }
|
79
138
|
|
80
|
-
|
81
|
-
its(['api_count']){
|
82
|
-
its(['disk_usage']){
|
83
|
-
its(['image_num']){
|
139
|
+
it_should_behave_like 'Basic response of request'
|
140
|
+
its(['api_count']){ should == 500 }
|
141
|
+
its(['disk_usage']){ should == 5500 }
|
142
|
+
its(['image_num']){ should == 2 }
|
84
143
|
end
|
85
144
|
end
|