tugboat 2.2.2 → 2.2.3
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/.rubocop.yml +520 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +0 -6
- data/README.md +34 -2
- data/Rakefile +6 -1
- data/bin/tugboat +2 -2
- data/features/cassettes/config/Array_of_SSH_Keys_in_Config.yml +1 -1
- data/features/cassettes/config/Single_SSH_key_as_number_in_config.yml +1 -1
- data/features/step_definitions/steps.rb +1 -1
- data/features/support/env.rb +7 -3
- data/lib/tugboat.rb +2 -2
- data/lib/tugboat/cli.rb +394 -444
- data/lib/tugboat/config.rb +43 -61
- data/lib/tugboat/middleware.rb +33 -33
- data/lib/tugboat/middleware/add_key.rb +12 -13
- data/lib/tugboat/middleware/ask_for_credentials.rb +12 -13
- data/lib/tugboat/middleware/base.rb +25 -20
- data/lib/tugboat/middleware/check_configuration.rb +3 -6
- data/lib/tugboat/middleware/check_credentials.rb +0 -1
- data/lib/tugboat/middleware/check_droplet_active.rb +2 -4
- data/lib/tugboat/middleware/check_droplet_inactive.rb +2 -4
- data/lib/tugboat/middleware/config.rb +3 -5
- data/lib/tugboat/middleware/confirm_action.rb +4 -6
- data/lib/tugboat/middleware/create_droplet.rb +27 -44
- data/lib/tugboat/middleware/custom_logger.rb +52 -54
- data/lib/tugboat/middleware/destroy_droplet.rb +5 -6
- data/lib/tugboat/middleware/destroy_image.rb +5 -6
- data/lib/tugboat/middleware/find_droplet.rb +43 -47
- data/lib/tugboat/middleware/find_image.rb +23 -29
- data/lib/tugboat/middleware/halt_droplet.rb +9 -10
- data/lib/tugboat/middleware/info_droplet.rb +30 -33
- data/lib/tugboat/middleware/info_image.rb +1 -1
- data/lib/tugboat/middleware/inject_client.rb +8 -10
- data/lib/tugboat/middleware/inject_configuration.rb +1 -2
- data/lib/tugboat/middleware/list_droplets.rb +9 -10
- data/lib/tugboat/middleware/list_images.rb +9 -9
- data/lib/tugboat/middleware/list_regions.rb +1 -1
- data/lib/tugboat/middleware/list_sizes.rb +1 -1
- data/lib/tugboat/middleware/list_ssh_keys.rb +1 -3
- data/lib/tugboat/middleware/password_reset.rb +6 -7
- data/lib/tugboat/middleware/rebuild_droplet.rb +7 -7
- data/lib/tugboat/middleware/resize_droplet.rb +6 -7
- data/lib/tugboat/middleware/restart_droplet.rb +4 -11
- data/lib/tugboat/middleware/snapshot_droplet.rb +7 -8
- data/lib/tugboat/middleware/ssh_droplet.rb +30 -31
- data/lib/tugboat/middleware/start_droplet.rb +5 -5
- data/lib/tugboat/middleware/wait_for_state.rb +2 -3
- data/lib/tugboat/version.rb +1 -1
- data/spec/cli/add_key_spec.rb +25 -28
- data/spec/cli/authorize_cli_spec.rb +57 -60
- data/spec/cli/config_cli_spec.rb +8 -11
- data/spec/cli/create_cli_spec.rb +40 -46
- data/spec/cli/debug_cli_spec.rb +29 -29
- data/spec/cli/destroy_cli_spec.rb +58 -60
- data/spec/cli/destroy_image_cli_spec.rb +42 -45
- data/spec/cli/droplets_cli_spec.rb +62 -64
- data/spec/cli/env_variable_spec.rb +14 -15
- data/spec/cli/halt_cli_spec.rb +65 -69
- data/spec/cli/help_cli_spec.rb +8 -8
- data/spec/cli/images_cli_spec.rb +28 -30
- data/spec/cli/info_cli_spec.rb +144 -147
- data/spec/cli/info_image_cli_spec.rb +57 -60
- data/spec/cli/keys_cli_spec.rb +8 -10
- data/spec/cli/password_reset_cli_spec.rb +56 -56
- data/spec/cli/rebuild_cli_spec.rb +194 -198
- data/spec/cli/regions_cli_spec.rb +8 -8
- data/spec/cli/resize_cli_spec.rb +54 -56
- data/spec/cli/restart_cli_spec.rb +53 -57
- data/spec/cli/sizes_cli_spec.rb +7 -8
- data/spec/cli/snapshot_cli_spec.rb +50 -53
- data/spec/cli/ssh_cli_spec.rb +41 -42
- data/spec/cli/start_cli_spec.rb +48 -52
- data/spec/cli/verify_cli_spec.rb +22 -25
- data/spec/cli/version_cli_spec.rb +6 -8
- data/spec/cli/wait_cli_spec.rb +50 -52
- data/spec/config_spec.rb +56 -57
- data/spec/middleware/base_spec.rb +5 -6
- data/spec/middleware/check_configuration_spec.rb +5 -7
- data/spec/middleware/check_credentials_spec.rb +9 -10
- data/spec/middleware/check_droplet_active_spec.rb +5 -7
- data/spec/middleware/check_droplet_inactive_spec.rb +5 -7
- data/spec/middleware/find_droplet_spec.rb +4 -5
- data/spec/middleware/find_image_spec.rb +4 -5
- data/spec/middleware/inject_client_spec.rb +9 -12
- data/spec/middleware/inject_configuration_spec.rb +4 -7
- data/spec/middleware/ssh_droplet_spec.rb +70 -73
- data/spec/shared/environment.rb +18 -20
- data/spec/spec_helper.rb +4 -4
- data/tugboat.gemspec +10 -6
- metadata +88 -17
data/spec/cli/images_cli_spec.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::CLI do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
stub_request(:get,
|
9
|
-
|
10
|
-
|
6
|
+
describe 'images' do
|
7
|
+
it 'shows all images by default' do
|
8
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
|
9
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
10
|
+
to_return(status: 200, body: fixture('show_images'), headers: {})
|
11
11
|
|
12
|
-
stub_request(:get,
|
13
|
-
|
14
|
-
|
12
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200&private=true').
|
13
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
14
|
+
to_return(status: 200, body: fixture('show_images_global'), headers: {})
|
15
15
|
|
16
|
-
|
16
|
+
cli.images
|
17
17
|
|
18
18
|
expect($stdout.string).to eq <<-eos
|
19
19
|
Showing both private and public images
|
@@ -73,17 +73,17 @@ Redmine on 14.04 (slug: redmine, id: 12438838, distro: Ubuntu)
|
|
73
73
|
eos
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
77
|
-
stub_request(:get,
|
78
|
-
|
79
|
-
|
76
|
+
it 'acknowledges when personal images are empty when showing default full list' do
|
77
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
|
78
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
79
|
+
to_return(status: 200, body: fixture('show_images'), headers: {})
|
80
80
|
|
81
|
-
stub_request(:get,
|
82
|
-
|
83
|
-
|
81
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200&private=true').
|
82
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
83
|
+
to_return(status: 200, body: fixture('show_images_empty'), headers: {})
|
84
84
|
|
85
|
-
|
86
|
-
|
85
|
+
cli.options = cli.options.merge(show_private_images: true)
|
86
|
+
cli.images
|
87
87
|
|
88
88
|
expect($stdout.string).to eq <<-eos
|
89
89
|
Showing both private and public images
|
@@ -143,17 +143,17 @@ Redmine on 14.04 (slug: redmine, id: 12438838, distro: Ubuntu)
|
|
143
143
|
eos
|
144
144
|
end
|
145
145
|
|
146
|
-
it
|
147
|
-
stub_request(:get,
|
148
|
-
|
149
|
-
|
146
|
+
it 'acknowledges when personal images are empty when just show private images flag given' do
|
147
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
|
148
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
149
|
+
to_return(status: 200, body: fixture('show_images'), headers: {})
|
150
150
|
|
151
|
-
stub_request(:get,
|
152
|
-
|
153
|
-
|
151
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200&private=true').
|
152
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
153
|
+
to_return(status: 200, body: fixture('show_images_empty'), headers: {})
|
154
154
|
|
155
|
-
|
156
|
-
|
155
|
+
cli.options = cli.options.merge(show_just_private_images: true)
|
156
|
+
cli.images
|
157
157
|
|
158
158
|
expect($stdout.string).to eq <<-eos
|
159
159
|
Showing just private images
|
@@ -162,6 +162,4 @@ No private images found
|
|
162
162
|
eos
|
163
163
|
end
|
164
164
|
end
|
165
|
-
|
166
165
|
end
|
167
|
-
|
data/spec/cli/info_cli_spec.rb
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::CLI do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
stub_request(:get,
|
9
|
-
|
10
|
-
|
6
|
+
describe 'info' do
|
7
|
+
it 'shows an error if response is not successful' do
|
8
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
9
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
10
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
11
11
|
|
12
|
-
stub_request(:get,
|
13
|
-
|
14
|
-
|
12
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
13
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
14
|
+
to_return(status: 404, body: fixture('not_found'), headers: {})
|
15
15
|
|
16
|
-
|
16
|
+
cli.options = cli.options.merge(id: 6_918_990)
|
17
17
|
|
18
|
-
expect {
|
18
|
+
expect { cli.info }.to raise_error(SystemExit)
|
19
19
|
|
20
20
|
expect($stdout.string).to eq <<-eos
|
21
21
|
Droplet id provided. Finding Droplet...Failed to find Droplet: The resource you were accessing could not be found.
|
22
22
|
eos
|
23
23
|
|
24
|
-
expect(a_request(:get,
|
24
|
+
expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200')).to have_been_made
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
stub_request(:get,
|
29
|
-
|
30
|
-
|
27
|
+
it 'shows a droplet with a fuzzy name' do
|
28
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
29
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
30
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
31
31
|
|
32
|
-
stub_request(:get,
|
33
|
-
|
34
|
-
|
32
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
33
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
34
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
35
35
|
|
36
|
-
stub_request(:get,
|
37
|
-
|
38
|
-
|
36
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
37
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
38
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
39
39
|
|
40
|
-
|
40
|
+
cli.info('example.com')
|
41
41
|
|
42
42
|
expect($stdout.string).to eq <<-eos
|
43
43
|
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
@@ -52,20 +52,19 @@ Image: 6918990 - ubuntu-14-04-x64
|
|
52
52
|
Size: 512MB
|
53
53
|
Backups Active: false
|
54
54
|
eos
|
55
|
-
|
56
55
|
end
|
57
56
|
|
58
|
-
it
|
59
|
-
stub_request(:get,
|
60
|
-
|
61
|
-
|
57
|
+
it 'shows a droplet made from a user image' do
|
58
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
59
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
60
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
62
61
|
|
63
|
-
stub_request(:get,
|
64
|
-
|
65
|
-
|
62
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
63
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
64
|
+
to_return(status: 200, body: fixture('show_droplet_user_image'), headers: {})
|
66
65
|
|
67
|
-
|
68
|
-
|
66
|
+
cli.options = cli.options.merge(id: 6_918_990)
|
67
|
+
cli.info
|
69
68
|
|
70
69
|
expect($stdout.string).to eq <<-eos
|
71
70
|
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
@@ -82,17 +81,17 @@ Backups Active: false
|
|
82
81
|
eos
|
83
82
|
end
|
84
83
|
|
85
|
-
it
|
86
|
-
stub_request(:get,
|
87
|
-
|
88
|
-
|
84
|
+
it 'shows a droplet with an id' do
|
85
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
86
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
87
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
89
88
|
|
90
|
-
stub_request(:get,
|
91
|
-
|
92
|
-
|
89
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
90
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
91
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
93
92
|
|
94
|
-
|
95
|
-
|
93
|
+
cli.options = cli.options.merge(id: 6_918_990)
|
94
|
+
cli.info
|
96
95
|
|
97
96
|
expect($stdout.string).to eq <<-eos
|
98
97
|
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
@@ -109,21 +108,21 @@ Backups Active: false
|
|
109
108
|
eos
|
110
109
|
end
|
111
110
|
|
112
|
-
it
|
113
|
-
stub_request(:get,
|
114
|
-
|
115
|
-
|
111
|
+
it 'shows a droplet with a name' do
|
112
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
113
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
114
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
116
115
|
|
117
|
-
stub_request(:get,
|
118
|
-
|
119
|
-
|
116
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
117
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
118
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
120
119
|
|
121
|
-
stub_request(:get,
|
122
|
-
|
123
|
-
|
120
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
121
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
122
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
124
123
|
|
125
|
-
|
126
|
-
|
124
|
+
cli.options = cli.options.merge(name: 'example.com')
|
125
|
+
cli.info
|
127
126
|
|
128
127
|
expect($stdout.string).to eq <<-eos
|
129
128
|
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
@@ -140,22 +139,22 @@ Backups Active: false
|
|
140
139
|
eos
|
141
140
|
end
|
142
141
|
|
143
|
-
it
|
144
|
-
stub_request(:get,
|
145
|
-
|
146
|
-
|
142
|
+
it 'allows choice of multiple droplets' do
|
143
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
144
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
145
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
147
146
|
|
148
|
-
stub_request(:get,
|
149
|
-
|
150
|
-
|
147
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
148
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
149
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
151
150
|
|
152
|
-
stub_request(:get,
|
153
|
-
|
154
|
-
|
151
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
152
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
153
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
155
154
|
|
156
155
|
$stdin.should_receive(:gets).and_return('0')
|
157
156
|
|
158
|
-
|
157
|
+
cli.info('examp')
|
159
158
|
|
160
159
|
expect($stdout.string).to eq <<-eos
|
161
160
|
Droplet fuzzy name provided. Finding droplet ID...Multiple droplets found.
|
@@ -176,22 +175,21 @@ Size: 512MB
|
|
176
175
|
Backups Active: false
|
177
176
|
eos
|
178
177
|
end
|
179
|
-
|
180
178
|
end
|
181
179
|
|
182
|
-
it
|
183
|
-
|
184
|
-
|
185
|
-
|
180
|
+
it 'shows a droplet with an id under porcelain mode' do
|
181
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
182
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
183
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
186
184
|
|
187
|
-
|
188
|
-
|
189
|
-
|
185
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
186
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
187
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
190
188
|
|
191
|
-
|
192
|
-
|
189
|
+
cli.options = cli.options.merge(id: '6918990', porcelain: true)
|
190
|
+
cli.info
|
193
191
|
|
194
|
-
|
192
|
+
expect($stdout.string).to eq <<-eos
|
195
193
|
name example.com
|
196
194
|
id 6918990
|
197
195
|
status active
|
@@ -202,25 +200,25 @@ image 6918990
|
|
202
200
|
size 512mb
|
203
201
|
backups_active false
|
204
202
|
eos
|
205
|
-
|
203
|
+
end
|
206
204
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
205
|
+
it 'shows a droplet with a name under porcelain mode' do
|
206
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
207
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
208
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
211
209
|
|
212
|
-
|
213
|
-
|
214
|
-
|
210
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
211
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
212
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
215
213
|
|
216
|
-
|
217
|
-
|
218
|
-
|
214
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
215
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
216
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
219
217
|
|
220
|
-
|
221
|
-
|
218
|
+
cli.options = cli.options.merge(name: 'example.com', porcelain: true)
|
219
|
+
cli.info
|
222
220
|
|
223
|
-
|
221
|
+
expect($stdout.string).to eq <<-eos
|
224
222
|
name example.com
|
225
223
|
id 6918990
|
226
224
|
status active
|
@@ -231,19 +229,19 @@ image 6918990
|
|
231
229
|
size 512mb
|
232
230
|
backups_active false
|
233
231
|
eos
|
234
|
-
|
232
|
+
end
|
235
233
|
|
236
|
-
it
|
237
|
-
stub_request(:get,
|
238
|
-
|
239
|
-
|
234
|
+
it 'shows a droplet attribute with an id' do
|
235
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
236
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
237
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
240
238
|
|
241
|
-
stub_request(:get,
|
242
|
-
|
243
|
-
|
239
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
240
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
241
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
244
242
|
|
245
|
-
|
246
|
-
|
243
|
+
cli.options = cli.options.merge(id: '6918990', attribute: 'ip4')
|
244
|
+
cli.info
|
247
245
|
|
248
246
|
expect($stdout.string).to eq <<-eos
|
249
247
|
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
@@ -251,21 +249,21 @@ Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
|
251
249
|
eos
|
252
250
|
end
|
253
251
|
|
254
|
-
it
|
255
|
-
stub_request(:get,
|
256
|
-
|
257
|
-
|
252
|
+
it 'shows a droplet attribute with a name' do
|
253
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
254
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
255
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
258
256
|
|
259
|
-
stub_request(:get,
|
260
|
-
|
261
|
-
|
257
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
258
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
259
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
262
260
|
|
263
|
-
stub_request(:get,
|
264
|
-
|
265
|
-
|
261
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
262
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
263
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
266
264
|
|
267
|
-
|
268
|
-
|
265
|
+
cli.options = cli.options.merge(name: 'example.com', attribute: 'ip4')
|
266
|
+
cli.info
|
269
267
|
|
270
268
|
expect($stdout.string).to eq <<-eos
|
271
269
|
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
@@ -273,19 +271,19 @@ Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
|
273
271
|
eos
|
274
272
|
end
|
275
273
|
|
276
|
-
it
|
277
|
-
|
278
|
-
|
279
|
-
|
274
|
+
it 'gives error if invalid attribute given' do
|
275
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
276
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
277
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
280
278
|
|
281
|
-
|
282
|
-
|
283
|
-
|
279
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
280
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
281
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
284
282
|
|
285
|
-
|
286
|
-
|
283
|
+
cli.options = cli.options.merge(id: 6_918_990, porcelain: true, attribute: 'foo')
|
284
|
+
expect { cli.info }.to raise_error(SystemExit)
|
287
285
|
|
288
|
-
|
286
|
+
expect($stdout.string).to eq <<-eos
|
289
287
|
Invalid attribute "foo"
|
290
288
|
Provide one of the following:
|
291
289
|
name
|
@@ -299,40 +297,39 @@ Provide one of the following:
|
|
299
297
|
size
|
300
298
|
backups_active
|
301
299
|
eos
|
302
|
-
|
300
|
+
end
|
303
301
|
|
304
|
-
it
|
305
|
-
|
306
|
-
|
307
|
-
|
302
|
+
it 'shows a droplet attribute with an id under porcelain mode' do
|
303
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
304
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
305
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
308
306
|
|
309
|
-
|
310
|
-
|
307
|
+
cli.options = cli.options.merge(id: '6918990', porcelain: true, attribute: 'ip4')
|
308
|
+
cli.info
|
311
309
|
|
312
|
-
|
310
|
+
expect($stdout.string).to eq <<-eos
|
313
311
|
104.131.186.241
|
314
312
|
eos
|
315
|
-
|
313
|
+
end
|
316
314
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
315
|
+
it 'shows a droplet attribute with a name under porcelain mode' do
|
316
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
317
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
318
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
321
319
|
|
322
|
-
|
323
|
-
|
324
|
-
|
320
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
321
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
322
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
325
323
|
|
326
|
-
|
327
|
-
|
328
|
-
|
324
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
325
|
+
with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
|
326
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
329
327
|
|
330
|
-
|
331
|
-
|
328
|
+
cli.options = cli.options.merge(name: 'example.com', porcelain: true, attribute: 'ip4')
|
329
|
+
cli.info
|
332
330
|
|
333
|
-
|
331
|
+
expect($stdout.string).to eq <<-eos
|
334
332
|
104.131.186.241
|
335
|
-
|
336
|
-
|
337
|
-
|
333
|
+
eos
|
334
|
+
end
|
338
335
|
end
|