smartdc 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +2 -1
- data/Gemfile +5 -2
- data/README.md +3 -4
- data/lib/smartdc/api/analytics.rb +1 -1
- data/lib/smartdc/api/analytics/heatmap.rb +1 -1
- data/lib/smartdc/api/datacenters.rb +1 -1
- data/lib/smartdc/api/datasets.rb +1 -1
- data/lib/smartdc/api/keys.rb +1 -1
- data/lib/smartdc/api/machine/metadata.rb +1 -1
- data/lib/smartdc/api/machine/snapshots.rb +1 -1
- data/lib/smartdc/api/machine/tags.rb +1 -1
- data/lib/smartdc/api/machines.rb +1 -1
- data/lib/smartdc/api/packages.rb +1 -0
- data/lib/smartdc/client.rb +1 -1
- data/lib/smartdc/error.rb +1 -1
- data/lib/smartdc/response/raise_error.rb +1 -1
- data/lib/smartdc/version.rb +1 -1
- data/smartdc.gemspec +1 -1
- data/spec/fixtures/datacenter.json +1 -1
- data/spec/fixtures/datacenters.json +1 -1
- data/spec/fixtures/machines.json +1 -1
- data/spec/fixtures/packages.json +1 -1
- data/spec/fixtures/snapshots.json +1 -1
- data/spec/fixtures/tag.json +1 -1
- data/spec/unit/smartdc/api/analytics_spec.rb +24 -29
- data/spec/unit/smartdc/api/datacenters_spec.rb +12 -15
- data/spec/unit/smartdc/api/datasets_spec.rb +14 -17
- data/spec/unit/smartdc/api/keys_spec.rb +24 -29
- data/spec/unit/smartdc/api/machine/metadata_spec.rb +19 -23
- data/spec/unit/smartdc/api/machine/snapshots_spec.rb +23 -107
- data/spec/unit/smartdc/api/machine/tags_spec.rb +23 -28
- data/spec/unit/smartdc/api/machines_spec.rb +24 -29
- data/spec/unit/smartdc/api/packages_spec.rb +13 -16
- data/spec/unit/smartdc/client_spec.rb +15 -14
- data/spec/unit/smartdc_spec.rb +4 -4
- metadata +4 -4
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -4,11 +4,14 @@ gem "rake"
|
|
4
4
|
|
5
5
|
group :development do
|
6
6
|
gem "bundler"
|
7
|
-
|
7
|
+
end
|
8
|
+
|
9
|
+
group :test do
|
10
|
+
gem "rspec", ">= 2.11"
|
8
11
|
end
|
9
12
|
|
10
13
|
group :runtime do
|
11
14
|
gem "faraday", "~> 0.8"
|
12
|
-
gem "thor", "~> 0.
|
15
|
+
gem "thor", "~> 0.18"
|
13
16
|
gem "terminal-table", "~> 1.4"
|
14
17
|
end
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
smartdc
|
2
2
|
=======
|
3
3
|
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/smartdc.png)](https://rubygems.org/gems/smartdc) [![Build Status](https://travis-ci.org/ogom/ruby-smartdc.png?branch=master)](https://travis-ci.org/ogom/ruby-smartdc)
|
5
|
+
|
4
6
|
```
|
5
7
|
.
|
6
8
|
|
|
@@ -10,7 +12,7 @@ smartdc
|
|
10
12
|
|
11
13
|
```
|
12
14
|
|
13
|
-
smartdc is Joyent's [SmartDataCenter](http://www.joyent.com/software/smartdatacenter) client and
|
15
|
+
smartdc is Joyent's [SmartDataCenter](http://www.joyent.com/software/smartdatacenter) client and SDC Command Line Interface.
|
14
16
|
[Joyent CloudAPI Documentation](http://apidocs.joyent.com/sdcapidoc/cloudapi/).
|
15
17
|
|
16
18
|
|
@@ -89,9 +91,6 @@ end
|
|
89
91
|
$ rake spec
|
90
92
|
```
|
91
93
|
|
92
|
-
[![Build Status](https://travis-ci.org/ogom/ruby-smartdc.png?branch=master)](https://travis-ci.org/ogom/ruby-smartdc)
|
93
|
-
|
94
|
-
|
95
94
|
## License
|
96
95
|
|
97
96
|
* MIT
|
data/lib/smartdc/api/datasets.rb
CHANGED
data/lib/smartdc/api/keys.rb
CHANGED
data/lib/smartdc/api/machines.rb
CHANGED
data/lib/smartdc/api/packages.rb
CHANGED
data/lib/smartdc/client.rb
CHANGED
data/lib/smartdc/error.rb
CHANGED
data/lib/smartdc/version.rb
CHANGED
data/smartdc.gemspec
CHANGED
@@ -18,6 +18,6 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.add_runtime_dependency(%q<faraday>, ["~> 0.8"])
|
21
|
-
gem.add_runtime_dependency(%q<thor>, ["~> 0.
|
21
|
+
gem.add_runtime_dependency(%q<thor>, ["~> 0.18"])
|
22
22
|
gem.add_runtime_dependency(%q<terminal-table>, ["~> 1.4"])
|
23
23
|
end
|
data/spec/fixtures/machines.json
CHANGED
data/spec/fixtures/packages.json
CHANGED
data/spec/fixtures/tag.json
CHANGED
@@ -1,52 +1,47 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
3
|
+
describe Smartdc::Api::Analytics do
|
4
|
+
|
5
|
+
let(:object) {Object.new}
|
6
|
+
let(:request) {Smartdc::Request}
|
7
|
+
let(:analytics) {Smartdc::Api::Analytics.new({})}
|
9
8
|
|
10
9
|
describe ".create" do
|
11
|
-
it "
|
12
|
-
|
13
|
-
analytic =
|
14
|
-
|
10
|
+
it "creates a instrumentation" do
|
11
|
+
object.stub(:content) {fixture('analytics')[0]}
|
12
|
+
analytic = object.content
|
13
|
+
request.stub_chain(:new, :post).with('my/analytics/instrumentations/', analytic) {object}
|
15
14
|
|
16
|
-
analytics
|
17
|
-
analytics.create(analytic).content['id'].should == analytic['id']
|
15
|
+
expect(analytics.create(analytic).content['id']).to eq(analytic['id'])
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
19
|
describe ".read" do
|
22
|
-
it "
|
23
|
-
|
24
|
-
id =
|
25
|
-
|
20
|
+
it "returns a instrumentation" do
|
21
|
+
object.stub(:content) {fixture('analytics')[0]}
|
22
|
+
id = object.content['id']
|
23
|
+
request.stub_chain(:new, :get).with('my/analytics/instrumentations/' + id) {object}
|
26
24
|
|
27
|
-
analytics
|
28
|
-
analytics.read(id).content['id'].should == id
|
25
|
+
expect(analytics.read(id).content['id']).to eq(id)
|
29
26
|
end
|
30
27
|
end
|
31
28
|
|
32
29
|
describe ".all" do
|
33
|
-
it "
|
34
|
-
|
35
|
-
|
30
|
+
it "returns some instrumentations" do
|
31
|
+
object.stub(:content) {fixture('analytics')}
|
32
|
+
request.stub_chain(:new, :get).with('my/analytics/instrumentations', {}) {object}
|
36
33
|
|
37
|
-
analytics
|
38
|
-
analytics.all.content.count.should > 0
|
34
|
+
expect(analytics.all.content.count).to be > 0
|
39
35
|
end
|
40
36
|
end
|
41
37
|
|
42
|
-
describe ".
|
43
|
-
it "
|
38
|
+
describe ".destroy" do
|
39
|
+
it "returns true when success" do
|
44
40
|
analytic = fixture('analytics')[0]
|
45
|
-
|
46
|
-
|
41
|
+
object.stub(:status) {204}
|
42
|
+
request.stub_chain(:new, :del).with('my/analytics/instrumentations/' + analytic['id']) {object}
|
47
43
|
|
48
|
-
analytics
|
49
|
-
analytics.destroy(analytic['id']).status.should == 204
|
44
|
+
expect(analytics.destroy(analytic['id']).status).to eq(204)
|
50
45
|
end
|
51
46
|
end
|
52
47
|
|
@@ -1,30 +1,27 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Smartdc::Api::Datacenters do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
5
|
+
let(:object) {Object.new}
|
6
|
+
let(:request) {Smartdc::Request}
|
7
|
+
let(:datacenters) {Smartdc::Api::Datacenters.new({})}
|
9
8
|
|
10
9
|
describe ".read" do
|
11
|
-
it "
|
12
|
-
|
10
|
+
it "returns a datacenter" do
|
11
|
+
object.stub(:content) {fixture('datacenter')}
|
13
12
|
name = fixture('datacenters').first[0]
|
14
|
-
|
13
|
+
request.stub_chain(:new, :get).with('my/datacenters/' + name) {object}
|
15
14
|
|
16
|
-
datacenters
|
17
|
-
datacenters.read(name).content['message'].should match(/#{name}/)
|
15
|
+
expect(datacenters.read(name).content['message']).to match(/#{name}/)
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
19
|
describe ".all" do
|
22
|
-
it "
|
23
|
-
|
24
|
-
|
20
|
+
it "returns some datacenter" do
|
21
|
+
object.stub(:content) {fixture('datacenters')}
|
22
|
+
request.stub_chain(:new, :get).with('my/datacenters', {}) {object}
|
25
23
|
|
26
|
-
datacenters
|
27
|
-
datacenters.all.content.count.should > 0
|
24
|
+
expect(datacenters.all.content.count).to be > 0
|
28
25
|
end
|
29
26
|
end
|
30
27
|
|
@@ -1,31 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Smartdc::Api::Datasets do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
5
|
+
let(:object) {Object.new}
|
6
|
+
let(:request) {Smartdc::Request}
|
7
|
+
let(:datasets) {Smartdc::Api::Datasets.new({})}
|
9
8
|
|
10
9
|
describe ".read" do
|
11
|
-
it "
|
12
|
-
|
13
|
-
id =
|
14
|
-
|
10
|
+
it "returns a dataset" do
|
11
|
+
object.stub(:content) {fixture('datasets')[0]}
|
12
|
+
id = object.content['id']
|
13
|
+
request.stub_chain(:new, :get).with('my/datasets/' + id) {object}
|
15
14
|
|
16
|
-
datasets
|
17
|
-
datasets.read(id).content['id'].should == id
|
15
|
+
expect(datasets.read(id).content['id']).to eq(id)
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
19
|
describe ".all" do
|
22
|
-
it "
|
23
|
-
|
24
|
-
|
20
|
+
it "returns some datasets" do
|
21
|
+
object.stub(:content) {fixture('datasets')}
|
22
|
+
request.stub_chain(:new, :get).with('my/datasets', {}) {object}
|
25
23
|
|
26
|
-
datasets
|
27
|
-
datasets.all.content.count.should > 0
|
24
|
+
expect(datasets.all.content.count).to be > 0
|
28
25
|
end
|
29
26
|
end
|
30
27
|
|
31
|
-
end
|
28
|
+
end
|
@@ -1,53 +1,48 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Smartdc::Api::Keys do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
5
|
+
let(:object) {Object.new}
|
6
|
+
let(:request) {Smartdc::Request}
|
7
|
+
let(:keys) {Smartdc::Api::Keys.new({})}
|
9
8
|
|
10
9
|
describe ".create" do
|
11
|
-
it "
|
12
|
-
|
13
|
-
key =
|
14
|
-
|
10
|
+
it "creates a key" do
|
11
|
+
object.stub(:content) {fixture('keys')[0]}
|
12
|
+
key = object.content
|
13
|
+
request.stub_chain(:new, :post).with('my/keys/', key) {object}
|
15
14
|
|
16
|
-
keys
|
17
|
-
keys.create(key).content['name'].should == key['name']
|
15
|
+
expect(keys.create(key).content['name']).to eq(key['name'])
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
19
|
describe ".read" do
|
22
|
-
it "
|
23
|
-
|
24
|
-
name =
|
25
|
-
|
20
|
+
it "returns a key" do
|
21
|
+
object.stub(:content) {fixture('keys')[0]}
|
22
|
+
name = object.content['name']
|
23
|
+
request.stub_chain(:new, :get).with('my/keys/' + name) {object}
|
26
24
|
|
27
|
-
keys
|
28
|
-
keys.read(name).content['name'].should == name
|
25
|
+
expect(keys.read(name).content['name']).to eq(name)
|
29
26
|
end
|
30
27
|
end
|
31
28
|
|
32
29
|
describe ".all" do
|
33
|
-
it "
|
34
|
-
|
35
|
-
|
30
|
+
it "returns some keys" do
|
31
|
+
object.stub(:content) {fixture('keys')}
|
32
|
+
request.stub_chain(:new, :get).with('my/keys', {}) {object}
|
36
33
|
|
37
|
-
keys
|
38
|
-
keys.all.content.count.should > 0
|
34
|
+
expect(keys.all.content.count).to be > 1
|
39
35
|
end
|
40
36
|
end
|
41
37
|
|
42
|
-
describe ".
|
43
|
-
it "
|
38
|
+
describe ".destroy" do
|
39
|
+
it "returns true when success" do
|
44
40
|
key = fixture('keys')[0]
|
45
|
-
|
46
|
-
|
41
|
+
object.stub(:status) {204}
|
42
|
+
request.stub_chain(:new, :del).with('my/keys/' + key['name']) {object}
|
47
43
|
|
48
|
-
keys
|
49
|
-
keys.destroy(key['name']).status.should == 204
|
44
|
+
expect(keys.destroy(key['name']).status).to eq(204)
|
50
45
|
end
|
51
46
|
end
|
52
47
|
|
53
|
-
end
|
48
|
+
end
|
@@ -1,41 +1,37 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
3
|
+
describe Smartdc::Api::Machine::Metadata do
|
4
|
+
|
5
|
+
let(:object) {Object.new}
|
6
|
+
let(:request) {Smartdc::Request}
|
7
|
+
let(:metadata) {Smartdc::Api::Machine::Metadata.new('id', {})}
|
9
8
|
|
10
9
|
describe ".create" do
|
11
|
-
it "
|
12
|
-
|
13
|
-
tag =
|
14
|
-
|
10
|
+
it "creates a metadata" do
|
11
|
+
object.stub(:content) {fixture('tag')}
|
12
|
+
tag = object.content
|
13
|
+
request.stub_chain(:new, :post).with('my/machines/id/metadata/', tag) {object}
|
15
14
|
|
16
|
-
metadata
|
17
|
-
metadata.create(tag).content.should == tag
|
15
|
+
expect(metadata.create(tag).content).to eq(tag)
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
19
|
describe ".read" do
|
22
|
-
it "
|
23
|
-
|
24
|
-
|
20
|
+
it "return some metadata" do
|
21
|
+
object.stub(:content) {fixture('tag')}
|
22
|
+
request.stub_chain(:new, :get).with('my/machines/id/metadata', {}) {object}
|
25
23
|
|
26
|
-
metadata
|
27
|
-
metadata.read.content.count.should > 0
|
24
|
+
expect(metadata.read.content.count).to be > 0
|
28
25
|
end
|
29
26
|
end
|
30
27
|
|
31
|
-
describe ".
|
32
|
-
it "
|
33
|
-
|
28
|
+
describe ".destroy" do
|
29
|
+
it "return a metadata" do
|
30
|
+
object.stub(:status) {204}
|
34
31
|
key = fixture('tag').first[0]
|
35
|
-
|
32
|
+
request.stub_chain(:new, :del).with('my/machines/id/metadata/' + key) {object}
|
36
33
|
|
37
|
-
metadata
|
38
|
-
metadata.destroy(key).status.should == 204
|
34
|
+
expect(metadata.destroy(key).status).to eq(204)
|
39
35
|
end
|
40
36
|
end
|
41
37
|
|
@@ -1,132 +1,48 @@
|
|
1
|
-
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
|
-
describe
|
3
|
+
describe Smartdc::Api::Machine::Snapshots do
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
5
|
+
let(:object) {Object.new}
|
6
|
+
let(:request) {Smartdc::Request}
|
7
|
+
let(:snapshots) {Smartdc::Api::Machine::Snapshots.new('id', {})}
|
10
8
|
|
11
9
|
describe ".create" do
|
12
|
-
it "
|
13
|
-
|
14
|
-
snapshot =
|
15
|
-
|
10
|
+
it "creates a snapshot" do
|
11
|
+
object.stub(:content) {fixture('snapshots')[0]}
|
12
|
+
snapshot = object.content
|
13
|
+
request.stub_chain(:new, :post).with('my/machines/id/snapshots/', snapshot) {object}
|
16
14
|
|
17
|
-
snapshots
|
18
|
-
snapshots.create(snapshot).content['name'].should == snapshot['name']
|
15
|
+
expect(snapshots.create(snapshot).content['name']).to eq(snapshot['name'])
|
19
16
|
end
|
20
17
|
end
|
21
18
|
|
22
19
|
describe ".read" do
|
23
|
-
it "
|
24
|
-
|
25
|
-
name =
|
26
|
-
|
20
|
+
it "return a snapshot" do
|
21
|
+
object.stub(:content) {fixture('snapshots')[0]}
|
22
|
+
name = object.content['name']
|
23
|
+
request.stub_chain(:new, :get).with('my/machines/id/snapshots/' + name) {object}
|
27
24
|
|
28
|
-
snapshots
|
29
|
-
snapshots.read(name).content['name'].should == name
|
25
|
+
expect(snapshots.read(name).content['name']).to eq(name)
|
30
26
|
end
|
31
27
|
end
|
32
28
|
|
33
29
|
describe ".all" do
|
34
|
-
it "
|
35
|
-
|
36
|
-
|
30
|
+
it "return some snapshots" do
|
31
|
+
object.stub(:content) {fixture('snapshots')}
|
32
|
+
request.stub_chain(:new, :get).with('my/machines/id/snapshots', {}) {object}
|
37
33
|
|
38
|
-
snapshots
|
39
|
-
snapshots.all.content.count.should > 0
|
34
|
+
expect(snapshots.all.content.count).to be > 0
|
40
35
|
end
|
41
36
|
end
|
42
37
|
|
43
|
-
describe ".
|
44
|
-
it "
|
45
|
-
|
38
|
+
describe ".destroy" do
|
39
|
+
it "return a snapshot" do
|
40
|
+
object.stub(:status) {204}
|
46
41
|
name = fixture('snapshots')[0]['name']
|
47
|
-
|
42
|
+
request.stub_chain(:new, :del).with('my/machines/id/snapshots/' + name) {object}
|
48
43
|
|
49
|
-
snapshots
|
50
|
-
snapshots.destroy(name).status.should == 204
|
44
|
+
expect(snapshots.destroy(name).status).to eq(204)
|
51
45
|
end
|
52
46
|
end
|
53
47
|
|
54
48
|
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
# require 'spec_helper'
|
64
|
-
|
65
|
-
# describe "Smartdc::Api::Machine::Snapshots" do
|
66
|
-
# before(:all) do
|
67
|
-
# @fixture = fixture('tag')
|
68
|
-
# @name = UUID.new.generate
|
69
|
-
# client.datasets.find.each do |dataset|
|
70
|
-
# if dataset.type == "smartmachine"
|
71
|
-
# @dataset_urn = dataset.urn
|
72
|
-
# break
|
73
|
-
# end
|
74
|
-
# end
|
75
|
-
|
76
|
-
# machine = {
|
77
|
-
# 'name' => @name,
|
78
|
-
# 'dataset' => @dataset_urn
|
79
|
-
# }
|
80
|
-
# @machine = client.machines.create machine
|
81
|
-
# machine = client.machines(@machine.id)
|
82
|
-
# 88.times do |i|
|
83
|
-
# break if machine.read.state == 'running'
|
84
|
-
# sleep i
|
85
|
-
# end
|
86
|
-
# 88.times do |i|
|
87
|
-
# break if machine.read.state == 'running'
|
88
|
-
# sleep i
|
89
|
-
# end
|
90
|
-
# machine.stop
|
91
|
-
# 88.times do |i|
|
92
|
-
# break if machine.read.state == 'stopped'
|
93
|
-
# sleep i
|
94
|
-
# end
|
95
|
-
# end
|
96
|
-
|
97
|
-
# describe ".create" do
|
98
|
-
# it "should return a snapshot" do
|
99
|
-
# snapshot = client.machines(@machine.id).snapshots.create @fixture
|
100
|
-
# snapshot.name.should eq @fixture['name']
|
101
|
-
# end
|
102
|
-
# end
|
103
|
-
|
104
|
-
# describe ".read" do
|
105
|
-
# it "should return a snapshot" do
|
106
|
-
# client.machines(@machine.id).snapshots('sample').read.name.should eq @fixture['name']
|
107
|
-
# end
|
108
|
-
# end
|
109
|
-
|
110
|
-
# describe ".find" do
|
111
|
-
# it "should return some snapshots" do
|
112
|
-
# client.machines(@machine.id).snapshots.find.count.should > 0
|
113
|
-
# end
|
114
|
-
# end
|
115
|
-
|
116
|
-
# describe ".delete" do
|
117
|
-
# it "should return true when success" do
|
118
|
-
# client.machines(@machine.id).snapshots('sample').delete.should be_nil
|
119
|
-
# end
|
120
|
-
# end
|
121
|
-
|
122
|
-
# after(:all) do
|
123
|
-
# sleep 8
|
124
|
-
# machine = client.machines(@machine.id)
|
125
|
-
# machine.stop
|
126
|
-
# 88.times do |i|
|
127
|
-
# break if machine.read.state == 'stopped'
|
128
|
-
# sleep i
|
129
|
-
# end
|
130
|
-
# client.machines(@machine.id).delete
|
131
|
-
# end
|
132
|
-
# end
|
@@ -1,52 +1,47 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Smartdc::Api::Machine::Tags do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
5
|
+
let(:object) {Object.new}
|
6
|
+
let(:request) {Smartdc::Request}
|
7
|
+
let(:tags) {Smartdc::Api::Machine::Tags.new('id', {})}
|
9
8
|
|
10
9
|
describe ".create" do
|
11
|
-
it "
|
12
|
-
|
13
|
-
tag =
|
14
|
-
|
10
|
+
it "creates a tag" do
|
11
|
+
object.stub(:content) {fixture('tag')}
|
12
|
+
tag = object.content
|
13
|
+
request.stub_chain(:new, :post).with('my/machines/id/tags/', tag) {object}
|
15
14
|
|
16
|
-
tags
|
17
|
-
tags.create(tag).content.should == tag
|
15
|
+
expect(tags.create(tag).content).to eq(tag)
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
19
|
describe ".read" do
|
22
|
-
it "
|
23
|
-
|
24
|
-
key =
|
25
|
-
|
20
|
+
it "return a tag" do
|
21
|
+
object.stub(:content) {fixture('tag')}
|
22
|
+
key = object.content.first[0]
|
23
|
+
request.stub_chain(:new, :get).with('my/machines/id/tags/' + key) {object}
|
26
24
|
|
27
|
-
tags
|
28
|
-
tags.read(key).content.first[0].should == key
|
25
|
+
expect(tags.read(key).content.first[0]).to eq(key)
|
29
26
|
end
|
30
27
|
end
|
31
28
|
|
32
29
|
describe ".all" do
|
33
|
-
it "
|
34
|
-
|
35
|
-
|
30
|
+
it "return some tags" do
|
31
|
+
object.stub(:content) {fixture('tag')}
|
32
|
+
request.stub_chain(:new, :get).with('my/machines/id/tags', {}) {object}
|
36
33
|
|
37
|
-
tags
|
38
|
-
tags.all.content.count.should > 0
|
34
|
+
expect(tags.all.content.count).to be > 0
|
39
35
|
end
|
40
36
|
end
|
41
37
|
|
42
|
-
describe ".
|
43
|
-
it "
|
44
|
-
|
38
|
+
describe ".destroy" do
|
39
|
+
it "return a tag" do
|
40
|
+
object.stub(:status) {204}
|
45
41
|
key = fixture('tag').first[0]
|
46
|
-
|
42
|
+
request.stub_chain(:new, :del).with('my/machines/id/tags/' + key) {object}
|
47
43
|
|
48
|
-
tags
|
49
|
-
tags.destroy(key).status.should == 204
|
44
|
+
expect(tags.destroy(key).status).to eq(204)
|
50
45
|
end
|
51
46
|
end
|
52
47
|
|
@@ -1,53 +1,48 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Smartdc::Api::Machines do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
5
|
+
let(:object) {Object.new}
|
6
|
+
let(:request) {Smartdc::Request}
|
7
|
+
let(:machines) {Smartdc::Api::Machines.new({})}
|
9
8
|
|
10
9
|
describe ".create" do
|
11
|
-
it "
|
12
|
-
|
13
|
-
machine =
|
14
|
-
|
10
|
+
it "creates a machine" do
|
11
|
+
object.stub(:content) {fixture('machines')[0]}
|
12
|
+
machine = object.content
|
13
|
+
request.stub_chain(:new, :post).with('my/machines/', machine) {object}
|
15
14
|
|
16
|
-
machines
|
17
|
-
machines.create(machine).content['name'].should == machine['name']
|
15
|
+
expect(machines.create(machine).content['name']).to eq(machine['name'])
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
19
|
describe ".read" do
|
22
|
-
it "
|
23
|
-
|
24
|
-
name =
|
25
|
-
|
20
|
+
it "returns a machine" do
|
21
|
+
object.stub(:content) {fixture('machines')[0]}
|
22
|
+
name = object.content['name']
|
23
|
+
request.stub_chain(:new, :get).with('my/machines/' + name) {object}
|
26
24
|
|
27
|
-
machines
|
28
|
-
machines.read(name).content['name'].should == name
|
25
|
+
expect(machines.read(name).content['name']).to eq(name)
|
29
26
|
end
|
30
27
|
end
|
31
28
|
|
32
29
|
describe ".all" do
|
33
|
-
it "
|
34
|
-
|
35
|
-
|
30
|
+
it "returns some machines" do
|
31
|
+
object.stub(:content) {fixture('machines')}
|
32
|
+
request.stub_chain(:new, :get).with('my/machines', {}) {object}
|
36
33
|
|
37
|
-
machines
|
38
|
-
machines.all.content.count.should > 0
|
34
|
+
expect(machines.all.content.count).to be > 1
|
39
35
|
end
|
40
36
|
end
|
41
37
|
|
42
|
-
describe ".
|
43
|
-
it "
|
38
|
+
describe ".destroy" do
|
39
|
+
it "returns true when success" do
|
44
40
|
machine = fixture('machines')[0]
|
45
|
-
|
46
|
-
|
41
|
+
object.stub(:status) {204}
|
42
|
+
request.stub_chain(:new, :del).with('my/machines/' + machine['name']) {object}
|
47
43
|
|
48
|
-
machines
|
49
|
-
machines.destroy(machine['name']).status.should == 204
|
44
|
+
expect(machines.destroy(machine['name']).status).to eq(204)
|
50
45
|
end
|
51
46
|
end
|
52
47
|
|
53
|
-
end
|
48
|
+
end
|
@@ -1,30 +1,27 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Smartdc::Api::Packages do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
5
|
+
let(:object) {Object.new}
|
6
|
+
let(:request) {Smartdc::Request}
|
7
|
+
let(:packages) {Smartdc::Api::Packages.new({})}
|
9
8
|
|
10
9
|
describe ".read" do
|
11
|
-
it "
|
12
|
-
|
13
|
-
name =
|
14
|
-
|
10
|
+
it "returns a package" do
|
11
|
+
object.stub(:content) {fixture('packages')[0]}
|
12
|
+
name = object.content['name']
|
13
|
+
request.stub_chain(:new, :get).with('my/packages/' + name) {object}
|
15
14
|
|
16
|
-
packages
|
17
|
-
packages.read(name).content['name'].should == name
|
15
|
+
expect(packages.read(name).content['name']).to eq(name)
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
19
|
describe ".all" do
|
22
|
-
it "
|
23
|
-
|
24
|
-
|
20
|
+
it "returns some packages" do
|
21
|
+
object.stub(:content) {fixture('packages')}
|
22
|
+
request.stub_chain(:new, :get).with('my/packages', {}) {object}
|
25
23
|
|
26
|
-
packages
|
27
|
-
packages.all.content.count.should > 0
|
24
|
+
expect(packages.all.content.count).to be > 1
|
28
25
|
end
|
29
26
|
end
|
30
27
|
|
@@ -1,39 +1,40 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Smartdc::Client do
|
4
4
|
describe ".keys" do
|
5
|
-
it "
|
6
|
-
Smartdc::Client.new.keys.
|
5
|
+
it "is a Smartdc::Api::Keys" do
|
6
|
+
expect(Smartdc::Client.new.keys).to be_a Smartdc::Api::Keys
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
describe ".datacenters" do
|
11
|
-
it "
|
12
|
-
Smartdc::Client.new.datacenters.
|
11
|
+
it "is a Smartdc::Api::Datacenters" do
|
12
|
+
expect(Smartdc::Client.new.datacenters).to be_a Smartdc::Api::Datacenters
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
describe ".datasets" do
|
17
|
-
it "
|
18
|
-
Smartdc::Client.new.datasets.
|
17
|
+
it "is a Smartdc::Api::Datasets" do
|
18
|
+
expect(Smartdc::Client.new.datasets).to be_a Smartdc::Api::Datasets
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe ".packages" do
|
23
|
-
it "
|
24
|
-
Smartdc::Client.new.packages.
|
23
|
+
it "is a Smartdc::Api::Packages" do
|
24
|
+
expect(Smartdc::Client.new.packages).to be_a Smartdc::Api::Packages
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe ".machines" do
|
29
|
-
it "
|
30
|
-
Smartdc::Client.new.machines.
|
29
|
+
it "is a Smartdc::Api::Machines" do
|
30
|
+
expect(Smartdc::Client.new.machines).to be_a Smartdc::Api::Machines
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe ".analytics" do
|
35
|
-
it "
|
36
|
-
Smartdc::Client.new.analytics.
|
35
|
+
it "is a Smartdc::Api::Analytics" do
|
36
|
+
expect(Smartdc::Client.new.analytics).to be_a Smartdc::Api::Analytics
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
|
+
end
|
data/spec/unit/smartdc_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Smartdc do
|
4
4
|
describe ".new" do
|
5
|
-
it "
|
6
|
-
Smartdc.new.
|
5
|
+
it "is a Smartdc::Client" do
|
6
|
+
expect(Smartdc.new).to be_a Smartdc::Client
|
7
7
|
end
|
8
8
|
end
|
9
|
-
end
|
9
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartdc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '0.
|
37
|
+
version: '0.18'
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: '0.
|
45
|
+
version: '0.18'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: terminal-table
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|