tugboat 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +5 -4
- data/CHANGELOG.md +325 -102
- data/CHANGELOG_old.md +150 -0
- data/Gemfile +6 -0
- data/README.md +12 -6
- data/Rakefile +7 -3
- data/features/step_definitions/steps.rb +0 -0
- data/features/support/env.rb +9 -0
- data/features/vagrant-adam/config_current_directory.feature +27 -0
- data/lib/tugboat/cli.rb +31 -3
- data/lib/tugboat/config.rb +13 -5
- data/lib/tugboat/middleware.rb +8 -0
- data/lib/tugboat/middleware/ask_for_credentials.rb +5 -4
- data/lib/tugboat/middleware/authentication_middleware.rb +2 -2
- data/lib/tugboat/middleware/config.rb +29 -0
- data/lib/tugboat/middleware/custom_logger.rb +2 -2
- data/lib/tugboat/middleware/find_droplet.rb +4 -0
- data/lib/tugboat/middleware/info_droplet.rb +5 -0
- data/lib/tugboat/middleware/inject_client.rb +1 -1
- data/lib/tugboat/middleware/list_droplets.rb +5 -1
- data/lib/tugboat/middleware/list_regions.rb +2 -2
- data/lib/tugboat/middleware/ssh_droplet.rb +17 -2
- data/lib/tugboat/version.rb +1 -1
- data/spec/cli/add_key_spec.rb +9 -9
- data/spec/cli/authorize_cli_spec.rb +76 -52
- data/spec/cli/create_cli_spec.rb +39 -4
- data/spec/cli/debug_cli_spec.rb +44 -0
- data/spec/cli/destroy_cli_spec.rb +30 -11
- data/spec/cli/destroy_image_cli_spec.rb +11 -11
- data/spec/cli/droplets_cli_spec.rb +6 -6
- data/spec/cli/halt_cli_spec.rb +9 -9
- data/spec/cli/images_cli_spec.rb +6 -6
- data/spec/cli/info_cli_spec.rb +42 -7
- data/spec/cli/info_image_cli_spec.rb +6 -6
- data/spec/cli/keys_cli_spec.rb +1 -1
- data/spec/cli/password_reset_cli_spec.rb +8 -8
- data/spec/cli/rebuild_cli_spec.rb +49 -49
- data/spec/cli/regions_cli_spec.rb +4 -4
- data/spec/cli/resize_cli_spec.rb +8 -8
- data/spec/cli/restart_cli_spec.rb +8 -8
- data/spec/cli/sizes_cli_spec.rb +1 -1
- data/spec/cli/snapshot_cli_spec.rb +7 -7
- data/spec/cli/ssh_cli_spec.rb +4 -4
- data/spec/cli/start_cli_spec.rb +7 -7
- data/spec/cli/verify_cli_spec.rb +10 -2
- data/spec/cli/wait_cli_spec.rb +6 -6
- data/spec/fixtures/500.html +68 -0
- data/spec/fixtures/show_droplet.json +1 -0
- data/spec/fixtures/show_droplet_fuzzy.json +13 -0
- data/spec/fixtures/show_droplet_inactive.json +1 -0
- data/spec/fixtures/show_droplets.json +2 -0
- data/spec/fixtures/show_droplets_fuzzy.json +35 -0
- data/spec/fixtures/show_droplets_inactive.json +2 -0
- data/spec/fixtures/show_regions.json +9 -6
- data/spec/middleware/base_spec.rb +1 -1
- data/spec/middleware/check_credentials_spec.rb +1 -1
- data/spec/middleware/inject_client_spec.rb +29 -0
- data/spec/middleware/inject_configuration_spec.rb +1 -1
- data/spec/middleware/ssh_droplet_spec.rb +30 -7
- data/spec/shared/environment.rb +1 -0
- data/spec/spec_helper.rb +11 -4
- data/tugboat.gemspec +9 -7
- metadata +64 -33
@@ -6,15 +6,15 @@ describe Tugboat::CLI do
|
|
6
6
|
describe "rebuild" do
|
7
7
|
it "rebuilds a droplet with a fuzzy name based on an image with a fuzy name" do
|
8
8
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
9
|
-
to_return(:status => 200, :body => fixture("show_droplets")
|
10
|
-
|
9
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
10
|
+
|
11
11
|
stub_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}").
|
12
|
-
to_return(:status => 200, :body => fixture("show_images")
|
12
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
|
13
13
|
|
14
14
|
stub_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478").
|
15
|
-
to_return(:status => 200, :body => '{ "status": "OK", "event_id": 7504 }'
|
15
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{ "status": "OK", "event_id": 7504 }')
|
16
16
|
|
17
|
-
$stdin.
|
17
|
+
expect($stdin).to receive(:gets).and_return("y")
|
18
18
|
|
19
19
|
@cli.rebuild("foo", "NLP Final")
|
20
20
|
|
@@ -26,15 +26,15 @@ Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 100823 (foo)\nImage
|
|
26
26
|
|
27
27
|
it "rebuilds a droplet with an id based on an image with a fuzy name" do
|
28
28
|
stub_request(:get, "https://api.digitalocean.com/droplets/#{droplet_id}?api_key=#{api_key}&client_id=#{client_key}").
|
29
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
30
|
-
|
29
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
30
|
+
|
31
31
|
stub_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}").
|
32
|
-
to_return(:status => 200, :body => fixture("show_images")
|
32
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
|
33
33
|
|
34
34
|
stub_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478").
|
35
|
-
to_return(:status => 200, :body => '{ "status": "OK", "event_id": 7504 }'
|
35
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{ "status": "OK", "event_id": 7504 }')
|
36
36
|
|
37
|
-
$stdin.
|
37
|
+
expect($stdin).to receive(:gets).and_return("y")
|
38
38
|
|
39
39
|
@cli.options = @cli.options.merge(:id => droplet_id)
|
40
40
|
@cli.rebuild("foo", "NLP Final")
|
@@ -47,15 +47,15 @@ Droplet id provided. Finding Droplet...done\e[0m, 100823 (foo)\nImage fuzzy name
|
|
47
47
|
|
48
48
|
it "rebuilds a droplet with a name based on an image with a fuzy name" do
|
49
49
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
50
|
-
to_return(:status => 200, :body => fixture("show_droplets"))
|
51
|
-
|
50
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
51
|
+
|
52
52
|
stub_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}").
|
53
|
-
to_return(:status => 200, :body => fixture("show_images")
|
53
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
|
54
54
|
|
55
55
|
stub_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478").
|
56
|
-
to_return(:status => 200, :body => '{ "status": "OK", "event_id": 7504 }'
|
56
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{ "status": "OK", "event_id": 7504 }')
|
57
57
|
|
58
|
-
$stdin.
|
58
|
+
expect($stdin).to receive(:gets).and_return("y")
|
59
59
|
|
60
60
|
@cli.options = @cli.options.merge(:name => droplet_name)
|
61
61
|
@cli.rebuild("foo", "NLP Final")
|
@@ -68,15 +68,15 @@ Droplet name provided. Finding droplet ID...done\e[0m, 100823 (foo)\nImage fuzzy
|
|
68
68
|
|
69
69
|
it "rebuilds a droplet with a fuzzy name based on an image with an id" do
|
70
70
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
71
|
-
to_return(:status => 200, :body => fixture("show_droplets")
|
72
|
-
|
71
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
72
|
+
|
73
73
|
stub_request(:get, "https://api.digitalocean.com/images/478?api_key=#{api_key}&client_id=#{client_key}").
|
74
|
-
to_return(:status => 200, :body => fixture("show_image")
|
74
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_image"))
|
75
75
|
|
76
76
|
stub_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478").
|
77
|
-
to_return(:status => 200, :body => '{ "status": "OK", "event_id": 7504 }'
|
77
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{ "status": "OK", "event_id": 7504 }')
|
78
78
|
|
79
|
-
$stdin.
|
79
|
+
expect($stdin).to receive(:gets).and_return("y")
|
80
80
|
|
81
81
|
@cli.options = @cli.options.merge(:image_id => 478)
|
82
82
|
@cli.rebuild("foo", "NLP Final")
|
@@ -89,15 +89,15 @@ Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 100823 (foo)\nImage
|
|
89
89
|
|
90
90
|
it "rebuilds a droplet with an id based on an image with an id" do
|
91
91
|
stub_request(:get, "https://api.digitalocean.com/droplets/#{droplet_id}?api_key=#{api_key}&client_id=#{client_key}").
|
92
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
93
|
-
|
92
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
93
|
+
|
94
94
|
stub_request(:get, "https://api.digitalocean.com/images/478?api_key=#{api_key}&client_id=#{client_key}").
|
95
|
-
to_return(:status => 200, :body => fixture("show_image")
|
95
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_image"))
|
96
96
|
|
97
97
|
stub_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478").
|
98
|
-
to_return(:status => 200, :body => '{ "status": "OK", "event_id": 7504 }'
|
98
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{ "status": "OK", "event_id": 7504 }')
|
99
99
|
|
100
|
-
$stdin.
|
100
|
+
expect($stdin).to receive(:gets).and_return("y")
|
101
101
|
|
102
102
|
@cli.options = @cli.options.merge(:id => droplet_id, :image_id => 478)
|
103
103
|
@cli.rebuild("foo", "NLP Final")
|
@@ -110,15 +110,15 @@ Droplet id provided. Finding Droplet...done\e[0m, 100823 (foo)\nImage id provide
|
|
110
110
|
|
111
111
|
it "rebuilds a droplet with a name based on an image with an id" do
|
112
112
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
113
|
-
to_return(:status => 200, :body => fixture("show_droplets"))
|
114
|
-
|
113
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
114
|
+
|
115
115
|
stub_request(:get, "https://api.digitalocean.com/images/478?api_key=#{api_key}&client_id=#{client_key}").
|
116
|
-
to_return(:status => 200, :body => fixture("show_image")
|
116
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_image"))
|
117
117
|
|
118
118
|
stub_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478").
|
119
|
-
to_return(:status => 200, :body => '{ "status": "OK", "event_id": 7504 }'
|
119
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{ "status": "OK", "event_id": 7504 }')
|
120
120
|
|
121
|
-
$stdin.
|
121
|
+
expect($stdin).to receive(:gets).and_return("y")
|
122
122
|
|
123
123
|
@cli.options = @cli.options.merge(:name => droplet_name, :image_id => 478)
|
124
124
|
@cli.rebuild("foo", "NLP Final")
|
@@ -131,15 +131,15 @@ Droplet name provided. Finding droplet ID...done\e[0m, 100823 (foo)\nImage id pr
|
|
131
131
|
|
132
132
|
it "rebuilds a droplet with a fuzzy name based on an image with a name" do
|
133
133
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
134
|
-
to_return(:status => 200, :body => fixture("show_droplets")
|
135
|
-
|
134
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
135
|
+
|
136
136
|
stub_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}").
|
137
|
-
to_return(:status => 200, :body => fixture("show_images")
|
137
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
|
138
138
|
|
139
139
|
stub_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478").
|
140
|
-
to_return(:status => 200, :body => '{ "status": "OK", "event_id": 7504 }'
|
140
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{ "status": "OK", "event_id": 7504 }')
|
141
141
|
|
142
|
-
$stdin.
|
142
|
+
expect($stdin).to receive(:gets).and_return("y")
|
143
143
|
|
144
144
|
@cli.options = @cli.options.merge(:image_name => "NLP Final")
|
145
145
|
@cli.rebuild("foo", "NLP Final")
|
@@ -152,15 +152,15 @@ Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 100823 (foo)\nImage
|
|
152
152
|
|
153
153
|
it "rebuilds a droplet with an id based on an image with a name" do
|
154
154
|
stub_request(:get, "https://api.digitalocean.com/droplets/#{droplet_id}?api_key=#{api_key}&client_id=#{client_key}").
|
155
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
156
|
-
|
155
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
156
|
+
|
157
157
|
stub_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}").
|
158
|
-
to_return(:status => 200, :body => fixture("show_images")
|
158
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
|
159
159
|
|
160
160
|
stub_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478").
|
161
|
-
to_return(:status => 200, :body => '{ "status": "OK", "event_id": 7504 }'
|
161
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{ "status": "OK", "event_id": 7504 }')
|
162
162
|
|
163
|
-
$stdin.
|
163
|
+
expect($stdin).to receive(:gets).and_return("y")
|
164
164
|
|
165
165
|
@cli.options = @cli.options.merge(:id => droplet_id, :image_name => "NLP Final")
|
166
166
|
@cli.rebuild("foo", "NLP Final")
|
@@ -173,15 +173,15 @@ Droplet id provided. Finding Droplet...done\e[0m, 100823 (foo)\nImage name provi
|
|
173
173
|
|
174
174
|
it "rebuilds a droplet with a name based on an image with a name" do
|
175
175
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
176
|
-
to_return(:status => 200, :body => fixture("show_droplets"))
|
177
|
-
|
176
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
177
|
+
|
178
178
|
stub_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}").
|
179
|
-
to_return(:status => 200, :body => fixture("show_images")
|
179
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
|
180
180
|
|
181
181
|
stub_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478").
|
182
|
-
to_return(:status => 200, :body => '{ "status": "OK", "event_id": 7504 }'
|
182
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{ "status": "OK", "event_id": 7504 }')
|
183
183
|
|
184
|
-
$stdin.
|
184
|
+
expect($stdin).to receive(:gets).and_return("y")
|
185
185
|
|
186
186
|
@cli.options = @cli.options.merge(:name => droplet_name, :image_name => "NLP Final")
|
187
187
|
@cli.rebuild("foo", "NLP Final")
|
@@ -194,13 +194,13 @@ Droplet name provided. Finding droplet ID...done\e[0m, 100823 (foo)\nImage name
|
|
194
194
|
|
195
195
|
it "rebuilds a droplet with confirm flag set" do
|
196
196
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
197
|
-
to_return(:status => 200, :body => fixture("show_droplets")
|
198
|
-
|
197
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
198
|
+
|
199
199
|
stub_request(:get, "https://api.digitalocean.com/images?api_key=#{api_key}&client_id=#{client_key}").
|
200
|
-
to_return(:status => 200, :body => fixture("show_images")
|
200
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
|
201
201
|
|
202
202
|
stub_request(:post, "https://api.digitalocean.com/droplets/100823/rebuild?api_key=#{api_key}&client_id=#{client_key}&image_id=478").
|
203
|
-
to_return(:status => 200, :body => '{ "status": "OK", "event_id": 7504 }'
|
203
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{ "status": "OK", "event_id": 7504 }')
|
204
204
|
|
205
205
|
@cli.options = @cli.options.merge(:confirm => "no")
|
206
206
|
@cli.rebuild("foo", "NLP Final")
|
@@ -6,15 +6,15 @@ describe Tugboat::CLI do
|
|
6
6
|
describe "regions" do
|
7
7
|
it "shows a list" do
|
8
8
|
stub_request(:get, "https://api.digitalocean.com/regions?api_key=#{api_key}&client_id=#{client_key}").
|
9
|
-
to_return(:status => 200, :body => fixture("show_regions"))
|
9
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_regions"))
|
10
10
|
|
11
11
|
@cli.regions
|
12
12
|
|
13
13
|
expect($stdout.string).to eq <<-eos
|
14
14
|
Regions:
|
15
|
-
Region 1 (id: 1)
|
16
|
-
Region 2 (id: 2)
|
17
|
-
Region 3 (id: 3)
|
15
|
+
Region 1 (id: 1) (slug: reg1)
|
16
|
+
Region 2 (id: 2) (slug: reg2)
|
17
|
+
Region 3 (id: 3) (slug: reg3)
|
18
18
|
eos
|
19
19
|
|
20
20
|
expect(a_request(:get, "https://api.digitalocean.com/regions?api_key=#{api_key}&client_id=#{client_key}")).
|
data/spec/cli/resize_cli_spec.rb
CHANGED
@@ -6,9 +6,9 @@ describe Tugboat::CLI do
|
|
6
6
|
describe "resize" do
|
7
7
|
it "resizes a droplet with a fuzzy name" do
|
8
8
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
9
|
-
to_return(:status => 200, :body => fixture("show_droplets"))
|
9
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
10
10
|
stub_request(:get, "https://api.digitalocean.com/droplets/100823/resize?api_key=#{api_key}&client_id=#{client_key}&size_id=123").
|
11
|
-
to_return(:status => 200, :body => '{"status":"OK","event_id":456}')
|
11
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{"status":"OK","event_id":456}')
|
12
12
|
|
13
13
|
@cli.options = @cli.options.merge(:size => 123)
|
14
14
|
@cli.resize("foo")
|
@@ -26,9 +26,9 @@ Queuing resize for 100823 (foo)...done
|
|
26
26
|
|
27
27
|
it "resizes a droplet with an id" do
|
28
28
|
stub_request(:get, "https://api.digitalocean.com/droplets/100823?api_key=#{api_key}&client_id=#{client_key}").
|
29
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
29
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
30
30
|
stub_request(:get, "https://api.digitalocean.com/droplets/100823/resize?api_key=#{api_key}&client_id=#{client_key}&size_id=123").
|
31
|
-
to_return(:status => 200, :body => '{"status":"OK","event_id":456}')
|
31
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{"status":"OK","event_id":456}')
|
32
32
|
|
33
33
|
@cli.options = @cli.options.merge(:size => 123, :id => 100823)
|
34
34
|
@cli.resize
|
@@ -46,9 +46,9 @@ Queuing resize for 100823 (foo)...done
|
|
46
46
|
|
47
47
|
it "resizes a droplet with a name" do
|
48
48
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
49
|
-
to_return(:status => 200, :body => fixture("show_droplets"))
|
49
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
50
50
|
stub_request(:get, "https://api.digitalocean.com/droplets/100823/resize?api_key=#{api_key}&client_id=#{client_key}&size_id=123").
|
51
|
-
to_return(:status => 200, :body => '{"status":"OK","event_id":456}')
|
51
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => '{"status":"OK","event_id":456}')
|
52
52
|
|
53
53
|
@cli.options = @cli.options.merge(:size => 123, :name => "foo")
|
54
54
|
@cli.resize
|
@@ -66,9 +66,9 @@ Queuing resize for 100823 (foo)...done
|
|
66
66
|
|
67
67
|
it "raises SystemExit when a request fails" do
|
68
68
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
69
|
-
to_return(:status => 200, :body => fixture("show_droplets"))
|
69
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
70
70
|
stub_request(:get, "https://api.digitalocean.com/droplets/100823/resize?api_key=#{api_key}&client_id=#{client_key}&size_id=123").
|
71
|
-
to_return(:status => 500, :body => '{"status":"ERROR","message":"Some error"}')
|
71
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 500, :body => '{"status":"ERROR","message":"Some error"}')
|
72
72
|
|
73
73
|
@cli.options = @cli.options.merge(:size => 123)
|
74
74
|
expect { @cli.resize("foo") }.to raise_error(SystemExit)
|
@@ -6,10 +6,10 @@ describe Tugboat::CLI do
|
|
6
6
|
describe "restarts a droplet" do
|
7
7
|
it "with a fuzzy name" do
|
8
8
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
9
|
-
to_return(:status => 200, :body => fixture("show_droplets"))
|
9
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
10
10
|
|
11
11
|
stub_request(:put, "https://api.digitalocean.com/droplets/100823/reboot?api_key=#{api_key}&client_id=#{client_key}").
|
12
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
12
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
13
13
|
|
14
14
|
@cli.restart("foo")
|
15
15
|
|
@@ -24,9 +24,9 @@ Queuing restart for 100823 (foo)...done
|
|
24
24
|
|
25
25
|
it "restarts a droplet hard when the hard option is used" do
|
26
26
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
27
|
-
to_return(:status => 200, :body => fixture("show_droplets"))
|
27
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
28
28
|
stub_request(:put, "https://api.digitalocean.com/droplets/100823/power_cycle?api_key=#{api_key}&client_id=#{client_key}").
|
29
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
29
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
30
30
|
|
31
31
|
@cli.options = @cli.options.merge(:hard => true)
|
32
32
|
@cli.restart("foo")
|
@@ -42,10 +42,10 @@ Queuing hard restart for 100823 (foo)...done
|
|
42
42
|
|
43
43
|
it "with an id" do
|
44
44
|
stub_request(:get, "https://api.digitalocean.com/droplets/#{droplet_id}?api_key=#{api_key}&client_id=#{client_key}").
|
45
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
45
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
46
46
|
|
47
47
|
stub_request(:put, "https://api.digitalocean.com/droplets/100823/reboot?api_key=#{api_key}&client_id=#{client_key}").
|
48
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
48
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
49
49
|
|
50
50
|
@cli.options = @cli.options.merge(:id => droplet_id)
|
51
51
|
@cli.restart
|
@@ -62,10 +62,10 @@ Queuing restart for 100823 (foo)...done
|
|
62
62
|
|
63
63
|
it "with a name" do
|
64
64
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
65
|
-
to_return(:status => 200, :body => fixture("show_droplets"))
|
65
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
66
66
|
|
67
67
|
stub_request(:put, "https://api.digitalocean.com/droplets/100823/reboot?api_key=#{api_key}&client_id=#{client_key}").
|
68
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
68
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
69
69
|
|
70
70
|
@cli.options = @cli.options.merge(:name => droplet_name)
|
71
71
|
@cli.restart
|
data/spec/cli/sizes_cli_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe Tugboat::CLI do
|
|
6
6
|
describe "sizes" do
|
7
7
|
it "shows a list" do
|
8
8
|
stub_request(:get, "https://api.digitalocean.com/sizes?api_key=#{api_key}&client_id=#{client_key}").
|
9
|
-
to_return(:status => 200, :body => fixture("show_sizes"))
|
9
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_sizes"))
|
10
10
|
|
11
11
|
@cli.sizes
|
12
12
|
|
@@ -8,10 +8,10 @@ describe Tugboat::CLI do
|
|
8
8
|
describe "snapshots a droplet" do
|
9
9
|
it "with a fuzzy name" do
|
10
10
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
11
|
-
to_return(:status => 200, :body => fixture("show_droplets_inactive"))
|
11
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets_inactive"))
|
12
12
|
|
13
13
|
stub_request(:get, "https://api.digitalocean.com/droplets/100823/snapshot?api_key=#{api_key}&client_id=#{client_key}&name=#{snapshot_name}").
|
14
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
14
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
15
15
|
|
16
16
|
@cli.snapshot(snapshot_name, "foo")
|
17
17
|
|
@@ -27,10 +27,10 @@ Queuing snapshot 'foo-snapshot' for 100823 (foo)...done
|
|
27
27
|
|
28
28
|
it "with an id" do
|
29
29
|
stub_request(:get, "https://api.digitalocean.com/droplets/#{droplet_id}?api_key=#{api_key}&client_id=#{client_key}").
|
30
|
-
to_return(:status => 200, :body => fixture("show_droplet_inactive"))
|
30
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet_inactive"))
|
31
31
|
|
32
32
|
stub_request(:get, "https://api.digitalocean.com/droplets/100823/snapshot?api_key=#{api_key}&client_id=#{client_key}&name=#{snapshot_name}").
|
33
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
33
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
34
34
|
|
35
35
|
@cli.options = @cli.options.merge(:id => droplet_id)
|
36
36
|
@cli.snapshot(snapshot_name)
|
@@ -48,10 +48,10 @@ Queuing snapshot 'foo-snapshot' for 100823 (foo)...done
|
|
48
48
|
|
49
49
|
it "with a name" do
|
50
50
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
51
|
-
to_return(:status => 200, :body => fixture("show_droplets_inactive"))
|
51
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets_inactive"))
|
52
52
|
|
53
53
|
stub_request(:get, "https://api.digitalocean.com/droplets/100823/snapshot?api_key=#{api_key}&client_id=#{client_key}&name=#{snapshot_name}").
|
54
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
54
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
55
55
|
|
56
56
|
@cli.options = @cli.options.merge(:name => droplet_name)
|
57
57
|
@cli.snapshot(snapshot_name)
|
@@ -68,7 +68,7 @@ Queuing snapshot 'foo-snapshot' for 100823 (foo)...done
|
|
68
68
|
|
69
69
|
it "does not snaphshot a droplet that is active" do
|
70
70
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
71
|
-
to_return(:status => 200, :body => fixture("show_droplets"))
|
71
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
72
72
|
|
73
73
|
@cli.options = @cli.options.merge(:name => droplet_name)
|
74
74
|
expect {@cli.snapshot(snapshot_name)}.to raise_error(SystemExit)
|
data/spec/cli/ssh_cli_spec.rb
CHANGED
@@ -6,8 +6,8 @@ describe Tugboat::CLI do
|
|
6
6
|
describe "ssh" do
|
7
7
|
it "tries to fetch the droplet's IP from the API" do
|
8
8
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
9
|
-
to_return(:status => 200, :body => fixture("show_droplets"))
|
10
|
-
Kernel.
|
9
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
10
|
+
allow(Kernel).to receive(:exec)
|
11
11
|
|
12
12
|
@cli.ssh("test222")
|
13
13
|
|
@@ -17,9 +17,9 @@ describe Tugboat::CLI do
|
|
17
17
|
|
18
18
|
it "does not allow ssh into a droplet that is inactive" do
|
19
19
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
20
|
-
to_return(:status => 200, :body => fixture("show_droplets_inactive"))
|
20
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets_inactive"))
|
21
21
|
|
22
|
-
Kernel.
|
22
|
+
allow(Kernel).to receive(:exec)
|
23
23
|
|
24
24
|
@cli.options = @cli.options.merge(:name => droplet_name)
|
25
25
|
|
data/spec/cli/start_cli_spec.rb
CHANGED
@@ -6,9 +6,9 @@ describe Tugboat::CLI do
|
|
6
6
|
describe "start" do
|
7
7
|
it "starts the droplet with a fuzzy name" do
|
8
8
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
9
|
-
to_return(:status => 200, :body => fixture("show_droplets_inactive"))
|
9
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets_inactive"))
|
10
10
|
stub_request(:put, "https://api.digitalocean.com/droplets/100823/power_on?api_key=#{api_key}&client_id=#{client_key}").
|
11
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
11
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
12
12
|
|
13
13
|
@cli.start("foo")
|
14
14
|
|
@@ -23,9 +23,9 @@ Queuing start for 100823 (foo)...done
|
|
23
23
|
|
24
24
|
it "starts the droplet with an id" do
|
25
25
|
stub_request(:get, "https://api.digitalocean.com/droplets/#{droplet_id}?api_key=#{api_key}&client_id=#{client_key}").
|
26
|
-
to_return(:status => 200, :body => fixture("show_droplet_inactive"))
|
26
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet_inactive"))
|
27
27
|
stub_request(:put, "https://api.digitalocean.com/droplets/100823/power_on?api_key=#{api_key}&client_id=#{client_key}").
|
28
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
28
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
29
29
|
|
30
30
|
@cli.options = @cli.options.merge(:id => droplet_id)
|
31
31
|
@cli.start
|
@@ -42,9 +42,9 @@ Queuing start for 100823 (foo)...done
|
|
42
42
|
|
43
43
|
it "starts the droplet with a name" do
|
44
44
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
45
|
-
to_return(:status => 200, :body => fixture("show_droplets_inactive"))
|
45
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets_inactive"))
|
46
46
|
stub_request(:put, "https://api.digitalocean.com/droplets/100823/power_on?api_key=#{api_key}&client_id=#{client_key}").
|
47
|
-
to_return(:status => 200, :body => fixture("show_droplet"))
|
47
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet"))
|
48
48
|
|
49
49
|
@cli.options = @cli.options.merge(:name => droplet_name)
|
50
50
|
@cli.start
|
@@ -60,7 +60,7 @@ Queuing start for 100823 (foo)...done
|
|
60
60
|
|
61
61
|
it "does not start a droplet that is inactive" do
|
62
62
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
63
|
-
to_return(:status => 200, :body => fixture("show_droplets"))
|
63
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplets"))
|
64
64
|
|
65
65
|
@cli.options = @cli.options.merge(:name => droplet_name)
|
66
66
|
expect {@cli.start}.to raise_error(SystemExit)
|
data/spec/cli/verify_cli_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe Tugboat::CLI do
|
|
6
6
|
describe "verify" do
|
7
7
|
it "returns confirmation text when verify passes" do
|
8
8
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
9
|
-
to_return(:status => 200)
|
9
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200)
|
10
10
|
@cli.verify
|
11
11
|
expect($stdout.string).to eq "Authentication with DigitalOcean was successful.\n"
|
12
12
|
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
@@ -14,12 +14,20 @@ describe Tugboat::CLI do
|
|
14
14
|
|
15
15
|
it "returns error string when verify fails" do
|
16
16
|
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
17
|
-
to_return(:status => 401, :body => '{"status":"ERROR", "error_message":"Access Denied"}')
|
17
|
+
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 401, :body => '{"status":"ERROR", "error_message":"Access Denied"}')
|
18
18
|
expect { @cli.verify }.to raise_error(SystemExit)
|
19
19
|
expect($stdout.string).to eq "\e[31mthe server responded with status 401!\e[0m\n\n\e[31mAccess Denied\e[0m\n\nDouble-check your parameters and configuration (in your ~/.tugboat file)\n"
|
20
20
|
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
21
21
|
end
|
22
22
|
|
23
|
+
it "returns error string when verify fails and a non-json reponse is given" do
|
24
|
+
stub_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}").
|
25
|
+
to_return(:headers => {'Content-Type' => 'text/html'}, :status => 500, :body => fixture('500','html'))
|
26
|
+
expect { @cli.verify }.to raise_error(SystemExit)
|
27
|
+
expect($stdout.string).to eq "\e[31mthe server responded with status 500!\e[0m\n"
|
28
|
+
expect(a_request(:get, "https://api.digitalocean.com/droplets?api_key=#{api_key}&client_id=#{client_key}")).to have_been_made
|
29
|
+
end
|
30
|
+
|
23
31
|
end
|
24
32
|
|
25
33
|
end
|