lita-digitalocean 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +178 -6
- data/lib/lita-digitalocean.rb +18 -0
- data/lib/lita/handlers/digitalocean.rb +0 -147
- data/lib/lita/handlers/digitalocean/base.rb +62 -0
- data/lib/lita/handlers/digitalocean/domain.rb +61 -0
- data/lib/lita/handlers/digitalocean/domain_record.rb +99 -0
- data/lib/lita/handlers/digitalocean/droplet.rb +236 -0
- data/lib/lita/handlers/digitalocean/image.rb +68 -0
- data/lib/lita/handlers/digitalocean/region.rb +23 -0
- data/lib/lita/handlers/digitalocean/size.rb +23 -0
- data/lib/lita/handlers/digitalocean/ssh_key.rb +94 -0
- data/lita-digitalocean.gemspec +4 -3
- data/locales/en.yml +142 -5
- data/spec/lita/handlers/digitalocean/base_spec.rb +39 -0
- data/spec/lita/handlers/digitalocean/domain_record_spec.rb +118 -0
- data/spec/lita/handlers/digitalocean/domain_spec.rb +85 -0
- data/spec/lita/handlers/digitalocean/droplet_spec.rb +238 -0
- data/spec/lita/handlers/digitalocean/image_spec.rb +121 -0
- data/spec/lita/handlers/digitalocean/region_spec.rb +44 -0
- data/spec/lita/handlers/digitalocean/size_spec.rb +44 -0
- data/spec/lita/handlers/digitalocean/ssh_key_spec.rb +119 -0
- metadata +44 -8
- data/spec/lita/handlers/digitalocean_spec.rb +0 -130
@@ -0,0 +1,85 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::Digitalocean::Domain, lita_handler: true do
|
4
|
+
it { routes_command("do domains create example.com 10.10.10.10").to(:create) }
|
5
|
+
it { routes_command("do domains delete example.com").to(:delete) }
|
6
|
+
it { routes_command("do domains list").to(:list) }
|
7
|
+
it { routes_command("do domains show example.com").to(:show) }
|
8
|
+
|
9
|
+
let(:client) { instance_double("::DigitalOcean::API", domains: client_domains) }
|
10
|
+
let(:client_domains) { instance_double("::DigitalOcean::Resource::Domain") }
|
11
|
+
|
12
|
+
before do
|
13
|
+
Lita.config.handlers.digitalocean = Lita::Config.new
|
14
|
+
Lita.config.handlers.digitalocean.tap do |config|
|
15
|
+
config.client_id = "CLIENT_ID"
|
16
|
+
config.api_key = "API_KEY"
|
17
|
+
end
|
18
|
+
|
19
|
+
allow(Lita::Authorization).to receive(:user_in_group?).with(
|
20
|
+
user,
|
21
|
+
:digitalocean_admins
|
22
|
+
).and_return(true)
|
23
|
+
|
24
|
+
allow(::DigitalOcean::API).to receive(:new).and_return(client)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#create" do
|
28
|
+
it "creates a new DNS record set" do
|
29
|
+
allow(client_domains).to receive(:create).with(
|
30
|
+
name: "example.com",
|
31
|
+
ip_address: "10.0.0.0"
|
32
|
+
).and_return(status: "OK", domain: { id: 123, name: "example.com" })
|
33
|
+
send_command("do domains create example.com 10.0.0.0")
|
34
|
+
expect(replies.last).to eq("Created new DNS record set for example.com.")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#delete" do
|
39
|
+
it "deletes a DNS record set" do
|
40
|
+
allow(client_domains).to receive(:delete).with("123").and_return(status: "OK")
|
41
|
+
send_command("do domains delete 123")
|
42
|
+
expect(replies.last).to eq("Deleted DNS record set.")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#list" do
|
47
|
+
it "lists all DNS record sets" do
|
48
|
+
allow(client_domains).to receive(:list).and_return(
|
49
|
+
status: "OK",
|
50
|
+
domains: [{
|
51
|
+
id: 123,
|
52
|
+
name: "example.com"
|
53
|
+
}, {
|
54
|
+
id: 456,
|
55
|
+
name: "another.example.com"
|
56
|
+
}]
|
57
|
+
)
|
58
|
+
send_command("do domains list")
|
59
|
+
expect(replies).to eq([
|
60
|
+
"ID: 123, Name: example.com",
|
61
|
+
"ID: 456, Name: another.example.com"
|
62
|
+
])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#show" do
|
67
|
+
it "responds with the details of the DNS record set" do
|
68
|
+
allow(client_domains).to receive(:show).with("123").and_return(
|
69
|
+
status: "OK",
|
70
|
+
domain: {
|
71
|
+
id: 123,
|
72
|
+
name: "example.com",
|
73
|
+
ttl: 1800,
|
74
|
+
live_zone_file: "LZF",
|
75
|
+
error: nil,
|
76
|
+
zone_file_with_error: nil
|
77
|
+
}
|
78
|
+
)
|
79
|
+
send_command("do domains show 123")
|
80
|
+
expect(replies.last).to eq(
|
81
|
+
"ID: 123, Name: example.com, TTL: 1800, Live Zone File: LZF, Error: , Zone File With Error: "
|
82
|
+
)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,238 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::Digitalocean::Droplet, lita_handler: true do
|
4
|
+
it do
|
5
|
+
routes_command(
|
6
|
+
"do droplets create example.com 512mb centos-5-8-x64 nyc1"
|
7
|
+
).to(:create)
|
8
|
+
end
|
9
|
+
it { routes_command("do droplets delete 123").to(:delete) }
|
10
|
+
it { routes_command("do droplets delete 123 --scrub").to(:delete) }
|
11
|
+
it { routes_command("do droplets list").to(:list) }
|
12
|
+
it { routes_command("do droplets password reset 123").to(:password_reset) }
|
13
|
+
it { routes_command("do droplets power cycle 123").to(:power_cycle) }
|
14
|
+
it { routes_command("do droplets power off 123").to(:power_off) }
|
15
|
+
it { routes_command("do droplets power on 123").to(:power_on) }
|
16
|
+
it { routes_command("do droplets reboot 123").to(:reboot) }
|
17
|
+
it { routes_command("do droplets rebuild 123 456").to(:rebuild) }
|
18
|
+
it { routes_command("do droplets resize 123 1gb").to(:resize) }
|
19
|
+
it { routes_command("do droplets restore 123 456").to(:restore) }
|
20
|
+
it { routes_command("do droplets show 123").to(:show) }
|
21
|
+
it { routes_command("do droplets shutdown 123").to(:shutdown) }
|
22
|
+
it { routes_command("do droplets snapshot 123 'My Snapshot'").to(:snapshot) }
|
23
|
+
|
24
|
+
let(:client) { instance_double("::DigitalOcean::API", droplets: client_droplets) }
|
25
|
+
let(:client_droplets) { instance_double("::DigitalOcean::Resource::Droplet") }
|
26
|
+
|
27
|
+
let(:do_ok) { { status: "OK" } }
|
28
|
+
|
29
|
+
before do
|
30
|
+
Lita.config.handlers.digitalocean = Lita::Config.new
|
31
|
+
Lita.config.handlers.digitalocean.tap do |config|
|
32
|
+
config.client_id = "CLIENT_ID"
|
33
|
+
config.api_key = "API_KEY"
|
34
|
+
end
|
35
|
+
|
36
|
+
allow(Lita::Authorization).to receive(:user_in_group?).with(
|
37
|
+
user,
|
38
|
+
:digitalocean_admins
|
39
|
+
).and_return(true)
|
40
|
+
|
41
|
+
allow(::DigitalOcean::API).to receive(:new).and_return(client)
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#create" do
|
45
|
+
it "creates a new droplet using slugs" do
|
46
|
+
allow(client_droplets).to receive(:create).with(
|
47
|
+
name: "example.com",
|
48
|
+
size_slug: "512mb",
|
49
|
+
image_slug: "centos-5-8-x64",
|
50
|
+
region_slug: "nyc1"
|
51
|
+
).and_return(status: "OK", droplet: { id: 123, name: "example.com" })
|
52
|
+
send_command("do droplets create example.com 512mb centos-5-8-x64 nyc1")
|
53
|
+
expect(replies.last).to eq("Created new droplet: 123 (example.com)")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "creates a new droplet using IDs" do
|
57
|
+
allow(client_droplets).to receive(:create).with(
|
58
|
+
name: "example.com",
|
59
|
+
size_id: "1",
|
60
|
+
image_id: "2",
|
61
|
+
region_id: "3"
|
62
|
+
).and_return(status: "OK", droplet: { id: 123, name: "example.com" })
|
63
|
+
send_command("do droplets create example.com 1 2 3")
|
64
|
+
expect(replies.last).to eq("Created new droplet: 123 (example.com)")
|
65
|
+
end
|
66
|
+
|
67
|
+
it "creates a new droplet with optional parameters" do
|
68
|
+
expect(client_droplets).to receive(:create).with(
|
69
|
+
hash_including(ssh_key_ids: "1,2,3", private_networking: true, backups_enabled: true)
|
70
|
+
).and_return(status: "OK", droplet: { id: 123, name: "example.com" })
|
71
|
+
send_command <<-COMMAND.chomp
|
72
|
+
do droplets create example.com 1 2 3 --ssh-key-ids 1,2,3 --private-networking --backups_enabled
|
73
|
+
COMMAND
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#delete" do
|
78
|
+
it "deletes a droplet" do
|
79
|
+
allow(client_droplets).to receive(:delete).with("123", {}).and_return(do_ok)
|
80
|
+
send_command("do droplets delete 123")
|
81
|
+
expect(replies.last).to eq("Deleted droplet: 123")
|
82
|
+
end
|
83
|
+
|
84
|
+
it "scrubs the disk before deleting the droplet" do
|
85
|
+
allow(client_droplets).to receive(:delete).with(
|
86
|
+
"123", {
|
87
|
+
scrub_data: true
|
88
|
+
}).and_return(do_ok)
|
89
|
+
send_command("do droplets delete 123 --scrub")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#list" do
|
94
|
+
let(:do_droplets) do
|
95
|
+
{
|
96
|
+
status: "OK",
|
97
|
+
droplets: [{
|
98
|
+
id: 123,
|
99
|
+
name: "image1",
|
100
|
+
ip_address: "1.2.3.4"
|
101
|
+
}, {
|
102
|
+
id: 456,
|
103
|
+
name: "image2",
|
104
|
+
ip_address: "5.6.7.8"
|
105
|
+
}]
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
109
|
+
it "lists all droplets" do
|
110
|
+
allow(client_droplets).to receive(:list).and_return(do_droplets)
|
111
|
+
send_command("do droplets list")
|
112
|
+
expect(replies).to eq([
|
113
|
+
"ID: 123, Name: image1, IP: 1.2.3.4",
|
114
|
+
"ID: 456, Name: image2, IP: 5.6.7.8"
|
115
|
+
])
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#password_reset" do
|
120
|
+
it "resets the root password" do
|
121
|
+
allow(client_droplets).to receive(:password_reset).with("123").and_return(do_ok)
|
122
|
+
send_command("do droplets password reset 123")
|
123
|
+
expect(replies.last).to eq("Password reset for droplet: 123")
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "#power_cycle" do
|
128
|
+
it "cycles the droplet's power" do
|
129
|
+
allow(client_droplets).to receive(:power_cycle).with("123").and_return(do_ok)
|
130
|
+
send_command("do droplets power cycle 123")
|
131
|
+
expect(replies.last).to eq("Power cycled for droplet: 123")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "#power_off" do
|
136
|
+
it "powers off the droplet" do
|
137
|
+
allow(client_droplets).to receive(:power_off).with("123").and_return(do_ok)
|
138
|
+
send_command("do droplets power off 123")
|
139
|
+
expect(replies.last).to eq("Powered off droplet: 123")
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "#power_on" do
|
144
|
+
it "powers on the droplet" do
|
145
|
+
allow(client_droplets).to receive(:power_on).with("123").and_return(do_ok)
|
146
|
+
send_command("do droplets power on 123")
|
147
|
+
expect(replies.last).to eq("Powered on droplet: 123")
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "#reboot" do
|
152
|
+
it "reboots the droplet" do
|
153
|
+
allow(client_droplets).to receive(:reboot).with("123").and_return(do_ok)
|
154
|
+
send_command("do droplets reboot 123")
|
155
|
+
expect(replies.last).to eq("Rebooted droplet: 123")
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "#rebuild" do
|
160
|
+
it "rebuilds the droplet with the provided image" do
|
161
|
+
allow(client_droplets).to receive(:rebuild).with("123", image_id: "456").and_return(do_ok)
|
162
|
+
send_command("do droplets rebuild 123 456")
|
163
|
+
expect(replies.last).to eq("Rebuilt droplet: 123")
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe "#resize" do
|
168
|
+
it "resizes the droplet with the provided size ID" do
|
169
|
+
allow(client_droplets).to receive(:resize).with("123", size_id: "456").and_return(do_ok)
|
170
|
+
send_command("do droplets resize 123 456")
|
171
|
+
expect(replies.last).to eq("Resized droplet: 123")
|
172
|
+
end
|
173
|
+
|
174
|
+
it "resizes the droplet with the provided size slug" do
|
175
|
+
allow(client_droplets).to receive(:resize).with("123", size_slug: "1gb").and_return(do_ok)
|
176
|
+
send_command("do droplets resize 123 1gb")
|
177
|
+
expect(replies.last).to eq("Resized droplet: 123")
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe "#restore" do
|
182
|
+
it "restores the droplet to the provided image" do
|
183
|
+
allow(client_droplets).to receive(:restore).with("123", image_id: "456").and_return(do_ok)
|
184
|
+
send_command("do droplets restore 123 456")
|
185
|
+
expect(replies.last).to eq("Restored droplet: 123")
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe "#show" do
|
190
|
+
it "responds with the details of the droplet" do
|
191
|
+
allow(client_droplets).to receive(:show).with("123").and_return(
|
192
|
+
status: "OK",
|
193
|
+
droplet: {
|
194
|
+
id: 123,
|
195
|
+
image_id: 456,
|
196
|
+
name: "My Droplet",
|
197
|
+
region_id: 1,
|
198
|
+
size_id: 33,
|
199
|
+
backups_active: true,
|
200
|
+
backups: [],
|
201
|
+
snapshots: [],
|
202
|
+
ip_address: "1.2.3.4",
|
203
|
+
private_ip_address: "5.6.7.8",
|
204
|
+
locked: false,
|
205
|
+
status: "active"
|
206
|
+
}
|
207
|
+
)
|
208
|
+
send_command("do droplets show 123")
|
209
|
+
expect(replies.last).to eq <<-DROPLET.chomp
|
210
|
+
ID: 123, Image ID: 456, Name: My Droplet, Region ID: 1, Size ID: 33, Backups active: true, \
|
211
|
+
Backups: [], Snapshots: [], IP address: 1.2.3.4, Private IP address: 5.6.7.8, Locked: false, \
|
212
|
+
Status: active
|
213
|
+
DROPLET
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
describe "#shutdown" do
|
218
|
+
it "shuts down the droplet" do
|
219
|
+
allow(client_droplets).to receive(:shutdown).with("123").and_return(do_ok)
|
220
|
+
send_command("do droplets shutdown 123")
|
221
|
+
expect(replies.last).to eq("Shut down droplet: 123")
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
describe "#snapshot" do
|
226
|
+
it "takes a snapshot of the droplet" do
|
227
|
+
allow(client_droplets).to receive(:snapshot).with("123", {}).and_return(do_ok)
|
228
|
+
send_command("do droplets snapshot 123")
|
229
|
+
expect(replies.last).to eq("Snapshotted droplet: 123")
|
230
|
+
end
|
231
|
+
|
232
|
+
it "takes a named snapshot of the droplet" do
|
233
|
+
allow(client_droplets).to receive(:snapshot).with("123", name: "My Droplet").and_return(do_ok)
|
234
|
+
send_command("do droplets snapshot 123 'My Droplet'")
|
235
|
+
expect(replies.last).to eq("Snapshotted droplet: 123")
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::Digitalocean::Image, lita_handler: true do
|
4
|
+
it { routes_command("do images delete 123").to(:delete) }
|
5
|
+
it { routes_command("do images list").to(:list) }
|
6
|
+
it { routes_command("do images list filter").to(:list) }
|
7
|
+
it { routes_command("do images show 123").to(:show) }
|
8
|
+
|
9
|
+
let(:client) { instance_double("::DigitalOcean::API", images: client_images) }
|
10
|
+
let(:client_images) { instance_double("::DigitalOcean::Resource::Image") }
|
11
|
+
|
12
|
+
before do
|
13
|
+
Lita.config.handlers.digitalocean = Lita::Config.new
|
14
|
+
Lita.config.handlers.digitalocean.tap do |config|
|
15
|
+
config.client_id = "CLIENT_ID"
|
16
|
+
config.api_key = "API_KEY"
|
17
|
+
end
|
18
|
+
|
19
|
+
allow(Lita::Authorization).to receive(:user_in_group?).with(
|
20
|
+
user,
|
21
|
+
:digitalocean_admins
|
22
|
+
).and_return(true)
|
23
|
+
|
24
|
+
allow(::DigitalOcean::API).to receive(:new).and_return(client)
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:public_image) do
|
28
|
+
{
|
29
|
+
id: 1601,
|
30
|
+
name: "CentOS 5.8 x64",
|
31
|
+
slug: "centos-5-8-x64",
|
32
|
+
distribution: "CentOS",
|
33
|
+
public: true,
|
34
|
+
regions: [1, 2, 3, 4, 5, 6],
|
35
|
+
region_slugs: %w(nyc1 ams1 sfo1 nyc2 ams2 sgp1)
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:public_image_message) do
|
40
|
+
<<-IMAGE.chomp
|
41
|
+
ID: 1601, Name: CentOS 5.8 x64, Slug: centos-5-8-x64, Distribution: CentOS, Public: true, \
|
42
|
+
Regions: [1,2,3,4,5,6], Region Slugs: [nyc1,ams1,sfo1,nyc2,ams2,sgp1]
|
43
|
+
IMAGE
|
44
|
+
end
|
45
|
+
|
46
|
+
let(:do_delete) { { status: "OK" } }
|
47
|
+
|
48
|
+
describe "#delete" do
|
49
|
+
it "responds with a success message" do
|
50
|
+
allow(client_images).to receive(:delete).with("123").and_return(do_delete)
|
51
|
+
send_command("do images delete 123")
|
52
|
+
expect(replies.last).to eq("Deleted image: 123")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#list" do
|
57
|
+
let(:private_image) do
|
58
|
+
{
|
59
|
+
"id" => 1602,
|
60
|
+
name: "CentOS 5.8 x32",
|
61
|
+
slug: "centos-5-8-x32",
|
62
|
+
distribution: "CentOS",
|
63
|
+
public: false,
|
64
|
+
regions: [1, 2, 3],
|
65
|
+
region_slugs: %w(nyc1 ams1 sfo1)
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
let(:do_images) do
|
70
|
+
{
|
71
|
+
status: "OK",
|
72
|
+
images: [public_image, private_image]
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
let(:do_public_images) do
|
77
|
+
{
|
78
|
+
status: "OK",
|
79
|
+
images: [public_image]
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
let(:do_private_images) do
|
84
|
+
{
|
85
|
+
status: "OK",
|
86
|
+
images: [private_image]
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
let(:private_image_message) do
|
91
|
+
<<-IMAGE.chomp
|
92
|
+
ID: 1602, Name: CentOS 5.8 x32, Slug: centos-5-8-x32, Distribution: CentOS, Public: false, \
|
93
|
+
Regions: [1,2,3], Region Slugs: [nyc1,ams1,sfo1]
|
94
|
+
IMAGE
|
95
|
+
end
|
96
|
+
|
97
|
+
it "responds with a list of all available images" do
|
98
|
+
allow(client_images).to receive(:list).and_return(do_images)
|
99
|
+
send_command("do images list")
|
100
|
+
expect(replies).to eq([public_image_message, private_image_message])
|
101
|
+
end
|
102
|
+
|
103
|
+
it "responds with a list of only public images" do
|
104
|
+
allow(client_images).to receive(:list).with(
|
105
|
+
filter: "global"
|
106
|
+
).and_return(do_public_images)
|
107
|
+
send_command("do images list global")
|
108
|
+
expect(replies.last).to eq(public_image_message)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#show" do
|
113
|
+
it "responds with the details of the image" do
|
114
|
+
allow(client_images).to receive(:show).with("123").and_return(
|
115
|
+
{ status: "OK", image: public_image }
|
116
|
+
)
|
117
|
+
send_command("do images show 123")
|
118
|
+
expect(replies.last).to eq(public_image_message)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::Digitalocean::Region, lita_handler: true do
|
4
|
+
it { routes_command("do regions list").to(:list) }
|
5
|
+
|
6
|
+
let(:client) { instance_double("::DigitalOcean::API", regions: client_regions) }
|
7
|
+
let(:client_regions) { instance_double("::DigitalOcean::Resource::Region") }
|
8
|
+
|
9
|
+
before do
|
10
|
+
Lita.config.handlers.digitalocean = Lita::Config.new
|
11
|
+
Lita.config.handlers.digitalocean.tap do |config|
|
12
|
+
config.client_id = "CLIENT_ID"
|
13
|
+
config.api_key = "API_KEY"
|
14
|
+
end
|
15
|
+
|
16
|
+
allow(Lita::Authorization).to receive(:user_in_group?).with(
|
17
|
+
user,
|
18
|
+
:digitalocean_admins
|
19
|
+
).and_return(true)
|
20
|
+
|
21
|
+
allow(::DigitalOcean::API).to receive(:new).and_return(client)
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:do_list) do
|
25
|
+
{
|
26
|
+
status: "OK",
|
27
|
+
regions: [
|
28
|
+
{ id: 1, name: "New York 1", slug: "nyc1" },
|
29
|
+
{ id: 2, name: "Amsterdam 1", slug: "ams1" }
|
30
|
+
]
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#list" do
|
35
|
+
it "responds with a list of all regions" do
|
36
|
+
allow(client_regions).to receive(:list).and_return(do_list)
|
37
|
+
send_command("do regions list")
|
38
|
+
expect(replies).to eq ([
|
39
|
+
"ID: 1, Name: New York 1, Slug: nyc1",
|
40
|
+
"ID: 2, Name: Amsterdam 1, Slug: ams1"
|
41
|
+
])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|