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.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +520 -0
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +0 -6
  5. data/README.md +34 -2
  6. data/Rakefile +6 -1
  7. data/bin/tugboat +2 -2
  8. data/features/cassettes/config/Array_of_SSH_Keys_in_Config.yml +1 -1
  9. data/features/cassettes/config/Single_SSH_key_as_number_in_config.yml +1 -1
  10. data/features/step_definitions/steps.rb +1 -1
  11. data/features/support/env.rb +7 -3
  12. data/lib/tugboat.rb +2 -2
  13. data/lib/tugboat/cli.rb +394 -444
  14. data/lib/tugboat/config.rb +43 -61
  15. data/lib/tugboat/middleware.rb +33 -33
  16. data/lib/tugboat/middleware/add_key.rb +12 -13
  17. data/lib/tugboat/middleware/ask_for_credentials.rb +12 -13
  18. data/lib/tugboat/middleware/base.rb +25 -20
  19. data/lib/tugboat/middleware/check_configuration.rb +3 -6
  20. data/lib/tugboat/middleware/check_credentials.rb +0 -1
  21. data/lib/tugboat/middleware/check_droplet_active.rb +2 -4
  22. data/lib/tugboat/middleware/check_droplet_inactive.rb +2 -4
  23. data/lib/tugboat/middleware/config.rb +3 -5
  24. data/lib/tugboat/middleware/confirm_action.rb +4 -6
  25. data/lib/tugboat/middleware/create_droplet.rb +27 -44
  26. data/lib/tugboat/middleware/custom_logger.rb +52 -54
  27. data/lib/tugboat/middleware/destroy_droplet.rb +5 -6
  28. data/lib/tugboat/middleware/destroy_image.rb +5 -6
  29. data/lib/tugboat/middleware/find_droplet.rb +43 -47
  30. data/lib/tugboat/middleware/find_image.rb +23 -29
  31. data/lib/tugboat/middleware/halt_droplet.rb +9 -10
  32. data/lib/tugboat/middleware/info_droplet.rb +30 -33
  33. data/lib/tugboat/middleware/info_image.rb +1 -1
  34. data/lib/tugboat/middleware/inject_client.rb +8 -10
  35. data/lib/tugboat/middleware/inject_configuration.rb +1 -2
  36. data/lib/tugboat/middleware/list_droplets.rb +9 -10
  37. data/lib/tugboat/middleware/list_images.rb +9 -9
  38. data/lib/tugboat/middleware/list_regions.rb +1 -1
  39. data/lib/tugboat/middleware/list_sizes.rb +1 -1
  40. data/lib/tugboat/middleware/list_ssh_keys.rb +1 -3
  41. data/lib/tugboat/middleware/password_reset.rb +6 -7
  42. data/lib/tugboat/middleware/rebuild_droplet.rb +7 -7
  43. data/lib/tugboat/middleware/resize_droplet.rb +6 -7
  44. data/lib/tugboat/middleware/restart_droplet.rb +4 -11
  45. data/lib/tugboat/middleware/snapshot_droplet.rb +7 -8
  46. data/lib/tugboat/middleware/ssh_droplet.rb +30 -31
  47. data/lib/tugboat/middleware/start_droplet.rb +5 -5
  48. data/lib/tugboat/middleware/wait_for_state.rb +2 -3
  49. data/lib/tugboat/version.rb +1 -1
  50. data/spec/cli/add_key_spec.rb +25 -28
  51. data/spec/cli/authorize_cli_spec.rb +57 -60
  52. data/spec/cli/config_cli_spec.rb +8 -11
  53. data/spec/cli/create_cli_spec.rb +40 -46
  54. data/spec/cli/debug_cli_spec.rb +29 -29
  55. data/spec/cli/destroy_cli_spec.rb +58 -60
  56. data/spec/cli/destroy_image_cli_spec.rb +42 -45
  57. data/spec/cli/droplets_cli_spec.rb +62 -64
  58. data/spec/cli/env_variable_spec.rb +14 -15
  59. data/spec/cli/halt_cli_spec.rb +65 -69
  60. data/spec/cli/help_cli_spec.rb +8 -8
  61. data/spec/cli/images_cli_spec.rb +28 -30
  62. data/spec/cli/info_cli_spec.rb +144 -147
  63. data/spec/cli/info_image_cli_spec.rb +57 -60
  64. data/spec/cli/keys_cli_spec.rb +8 -10
  65. data/spec/cli/password_reset_cli_spec.rb +56 -56
  66. data/spec/cli/rebuild_cli_spec.rb +194 -198
  67. data/spec/cli/regions_cli_spec.rb +8 -8
  68. data/spec/cli/resize_cli_spec.rb +54 -56
  69. data/spec/cli/restart_cli_spec.rb +53 -57
  70. data/spec/cli/sizes_cli_spec.rb +7 -8
  71. data/spec/cli/snapshot_cli_spec.rb +50 -53
  72. data/spec/cli/ssh_cli_spec.rb +41 -42
  73. data/spec/cli/start_cli_spec.rb +48 -52
  74. data/spec/cli/verify_cli_spec.rb +22 -25
  75. data/spec/cli/version_cli_spec.rb +6 -8
  76. data/spec/cli/wait_cli_spec.rb +50 -52
  77. data/spec/config_spec.rb +56 -57
  78. data/spec/middleware/base_spec.rb +5 -6
  79. data/spec/middleware/check_configuration_spec.rb +5 -7
  80. data/spec/middleware/check_credentials_spec.rb +9 -10
  81. data/spec/middleware/check_droplet_active_spec.rb +5 -7
  82. data/spec/middleware/check_droplet_inactive_spec.rb +5 -7
  83. data/spec/middleware/find_droplet_spec.rb +4 -5
  84. data/spec/middleware/find_image_spec.rb +4 -5
  85. data/spec/middleware/inject_client_spec.rb +9 -12
  86. data/spec/middleware/inject_configuration_spec.rb +4 -7
  87. data/spec/middleware/ssh_droplet_spec.rb +70 -73
  88. data/spec/shared/environment.rb +18 -20
  89. data/spec/spec_helper.rb +4 -4
  90. data/tugboat.gemspec +10 -6
  91. metadata +88 -17
@@ -1,15 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Tugboat::CLI do
4
- include_context "spec"
4
+ include_context 'spec'
5
5
 
6
- describe "regions" do
7
- it "shows a list" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/regions?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.9.2'}).
10
- to_return(:status => 200, :body => fixture("show_regions"), :headers => {'Content-Type' => 'application/json'},)
6
+ describe 'regions' do
7
+ it 'shows a list' do
8
+ stub_request(:get, 'https://api.digitalocean.com/v2/regions?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_regions'), headers: { 'Content-Type' => 'application/json' })
11
11
 
12
- @cli.regions
12
+ cli.regions
13
13
 
14
14
  expect($stdout.string).to eq <<-eos
15
15
  Regions:
@@ -24,7 +24,7 @@ San Francisco 1 (slug: sfo1)
24
24
  Singapore 1 (slug: sgp1)
25
25
  eos
26
26
 
27
- expect(a_request(:get, "https://api.digitalocean.com/v2/regions?per_page=200")).
27
+ expect(a_request(:get, 'https://api.digitalocean.com/v2/regions?per_page=200')).
28
28
  to have_been_made
29
29
  end
30
30
  end
@@ -1,25 +1,25 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Tugboat::CLI do
4
- include_context "spec"
4
+ include_context 'spec'
5
5
 
6
- describe "resize" do
7
- it "resizes a droplet with a fuzzy name" 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.9.2'}).
10
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
6
+ describe 'resize' do
7
+ it 'resizes a droplet with a fuzzy name' 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, "https://api.digitalocean.com/v2/droplets?page=1&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.9.2'}).
14
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
12
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&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: 200, body: fixture('show_droplets'), headers: {})
15
15
 
16
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
17
- with(:body => "{\"type\":\"resize\",\"size\":\"1gb\"}",
18
- :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.9.2'}).
19
- to_return(:status => 200, :body => fixture('resize_droplet'), :headers => {})
16
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
17
+ with(body: '{"type":"resize","size":"1gb"}',
18
+ 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' }).
19
+ to_return(status: 200, body: fixture('resize_droplet'), headers: {})
20
20
 
21
- @cli.options = @cli.options.merge(:size => '1gb')
22
- @cli.resize("example.com")
21
+ cli.options = cli.options.merge(size: '1gb')
22
+ cli.resize('example.com')
23
23
 
24
24
  expect($stdout.string).to eq <<-eos
25
25
  Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
@@ -27,22 +27,22 @@ Queuing resize for 6918990 (example.com)...Resize complete!
27
27
  eos
28
28
  end
29
29
 
30
- it "resizes a droplet with an id" do
31
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
32
- 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.9.2'}).
33
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
30
+ it 'resizes a droplet with an id' do
31
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
32
+ 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' }).
33
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
34
34
 
35
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
36
- 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.9.2'}).
37
- to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
35
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
36
+ 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' }).
37
+ to_return(status: 200, body: fixture('show_droplet'), headers: {})
38
38
 
39
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
40
- with(:body => "{\"type\":\"resize\",\"size\":\"1gb\"}",
41
- :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.9.2'}).
42
- to_return(:status => 200, :body => fixture('resize_droplet'), :headers => {})
39
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
40
+ with(body: '{"type":"resize","size":"1gb"}',
41
+ 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' }).
42
+ to_return(status: 200, body: fixture('resize_droplet'), headers: {})
43
43
 
44
- @cli.options = @cli.options.merge(:size => '1gb', :id => 6918990)
45
- @cli.resize
44
+ cli.options = cli.options.merge(size: '1gb', id: 6_918_990)
45
+ cli.resize
46
46
 
47
47
  expect($stdout.string).to eq <<-eos
48
48
  Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
@@ -50,52 +50,50 @@ Queuing resize for 6918990 (example.com)...Resize complete!
50
50
  eos
51
51
  end
52
52
 
53
- it "resizes a droplet with a name" do
54
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
55
- 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.9.2'}).
56
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
53
+ it 'resizes a droplet with a name' do
54
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
55
+ 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' }).
56
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
57
57
 
58
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
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.9.2'}).
60
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
58
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
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: {})
61
61
 
62
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
63
- with(:body => "{\"type\":\"resize\",\"size\":\"1gb\"}",
64
- :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.9.2'}).
65
- to_return(:status => 200, :body => fixture('resize_droplet'), :headers => {})
62
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
63
+ with(body: '{"type":"resize","size":"1gb"}',
64
+ 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' }).
65
+ to_return(status: 200, body: fixture('resize_droplet'), headers: {})
66
66
 
67
- @cli.options = @cli.options.merge(:size => '1gb', :name => "example.com")
68
- @cli.resize
67
+ cli.options = cli.options.merge(size: '1gb', name: 'example.com')
68
+ cli.resize
69
69
 
70
70
  expect($stdout.string).to eq <<-eos
71
71
  Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
72
72
  Queuing resize for 6918990 (example.com)...Resize complete!
73
73
  eos
74
-
75
74
  end
76
75
 
77
- it "raises SystemExit when a request fails" do
78
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
79
- 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.9.2'}).
80
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
76
+ it 'raises SystemExit when a request fails' do
77
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
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_droplets'), headers: {})
81
80
 
82
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
83
- 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.9.2'}).
84
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
81
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
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_droplets'), headers: {})
85
84
 
86
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
87
- with(:body => "{\"type\":\"resize\",\"size\":\"1gb\"}",
88
- :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.9.2'}).
89
- to_return(:headers => {'Content-Type' => 'application/json'}, :status => 500, :body => '{"status":"ERROR","message":"Some error"}')
85
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
86
+ with(body: '{"type":"resize","size":"1gb"}',
87
+ 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' }).
88
+ to_return(headers: { 'Content-Type' => 'application/json' }, status: 500, body: '{"status":"ERROR","message":"Some error"}')
90
89
 
91
- @cli.options = @cli.options.merge(:size => '1gb')
92
- expect { @cli.resize("example.com") }.to raise_error(SystemExit)
90
+ cli.options = cli.options.merge(size: '1gb')
91
+ expect { cli.resize('example.com') }.to raise_error(SystemExit)
93
92
 
94
93
  expect($stdout.string).to eq <<-eos
95
94
  Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
96
95
  Queuing resize for 6918990 (example.com)...Failed to resize Droplet: Some error
97
96
  eos
98
-
99
97
  end
100
98
  end
101
99
  end
@@ -1,48 +1,47 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Tugboat::CLI do
4
- include_context "spec"
4
+ include_context 'spec'
5
5
 
6
- describe "restarts a droplet" do
7
- it "with a fuzzy name" 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.9.2'}).
10
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
6
+ describe 'restarts a droplet' do
7
+ it 'with a fuzzy name' 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, "https://api.digitalocean.com/v2/droplets?page=1&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.9.2'}).
14
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
12
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&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: 200, body: fixture('show_droplets'), headers: {})
15
15
 
16
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
17
- with(:body => "{\"type\":\"reboot\"}",
18
- :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.9.2'}).
19
- to_return(:status => 200, :body => fixture('restart_response'), :headers => {})
16
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
17
+ with(body: '{"type":"reboot"}',
18
+ 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' }).
19
+ to_return(status: 200, body: fixture('restart_response'), headers: {})
20
20
 
21
- @cli.restart("example.com")
21
+ cli.restart('example.com')
22
22
 
23
23
  expect($stdout.string).to eq <<-eos
24
24
  Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
25
25
  Queuing restart for 6918990 (example.com)...Restart complete!
26
26
  eos
27
-
28
27
  end
29
28
 
30
- it "restarts a droplet hard when the hard option is used" do
31
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
32
- 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.9.2'}).
33
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
29
+ it 'restarts a droplet hard when the hard option is used' do
30
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
31
+ 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' }).
32
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
34
33
 
35
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
36
- 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.9.2'}).
37
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
34
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
35
+ 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' }).
36
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
38
37
 
39
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
40
- with(:body => "{\"type\":\"power_cycle\"}",
41
- :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.9.2'}).
42
- to_return(:status => 200, :body => "", :headers => {})
38
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
39
+ with(body: '{"type":"power_cycle"}',
40
+ 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' }).
41
+ to_return(status: 200, body: '', headers: {})
43
42
 
44
- @cli.options = @cli.options.merge(:hard => true)
45
- @cli.restart("example.com")
43
+ cli.options = cli.options.merge(hard: true)
44
+ cli.restart('example.com')
46
45
 
47
46
  expect($stdout.string).to eq <<-eos
48
47
  Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
@@ -50,22 +49,22 @@ Queuing hard restart for 6918990 (example.com)...Restart complete!
50
49
  eos
51
50
  end
52
51
 
53
- it "with an id" do
54
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
55
- 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.9.2'}).
56
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
52
+ it 'with an id' do
53
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
54
+ 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' }).
55
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
57
56
 
58
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
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.9.2'}).
60
- to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
57
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
58
+ 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' }).
59
+ to_return(status: 200, body: fixture('show_droplet'), headers: {})
61
60
 
62
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
63
- with(:body => "{\"type\":\"reboot\"}",
64
- :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.9.2'}).
65
- to_return(:status => 200, :body => fixture('restart_response'), :headers => {})
61
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
62
+ with(body: '{"type":"reboot"}',
63
+ 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('restart_response'), headers: {})
66
65
 
67
- @cli.options = @cli.options.merge(:id => '6918990')
68
- @cli.restart
66
+ cli.options = cli.options.merge(id: '6918990')
67
+ cli.restart
69
68
 
70
69
  expect($stdout.string).to eq <<-eos
71
70
  Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
@@ -73,30 +72,27 @@ Queuing restart for 6918990 (example.com)...Restart complete!
73
72
  eos
74
73
  end
75
74
 
75
+ it 'with a name' do
76
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
77
+ 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' }).
78
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
76
79
 
77
- it "with a name" do
78
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
79
- 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.9.2'}).
80
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
81
-
82
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
83
- 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.9.2'}).
84
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
80
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
81
+ 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' }).
82
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
85
83
 
86
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
87
- with(:body => "{\"type\":\"reboot\"}",
88
- :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.9.2'}).
89
- to_return(:status => 200, :body => fixture('restart_response'), :headers => {})
84
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
85
+ with(body: '{"type":"reboot"}',
86
+ 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('restart_response'), headers: {})
90
88
 
91
- @cli.options = @cli.options.merge(:name => 'example.com')
92
- @cli.restart
89
+ cli.options = cli.options.merge(name: 'example.com')
90
+ cli.restart
93
91
 
94
92
  expect($stdout.string).to eq <<-eos
95
93
  Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
96
94
  Queuing restart for 6918990 (example.com)...Restart complete!
97
95
  eos
98
96
  end
99
-
100
97
  end
101
-
102
98
  end
@@ -1,16 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Tugboat::CLI do
4
- include_context "spec"
4
+ include_context 'spec'
5
5
 
6
- describe "sizes" do
7
- it "shows a list" do
6
+ describe 'sizes' do
7
+ it 'shows a list' do
8
+ stub_request(:get, 'https://api.digitalocean.com/v2/sizes?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(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_sizes'))
8
11
 
9
- stub_request(:get, "https://api.digitalocean.com/v2/sizes?per_page=200").
10
- 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.9.2'}).
11
- to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_sizes"))
12
-
13
- @cli.sizes
12
+ cli.sizes
14
13
 
15
14
  expect($stdout.string).to eq <<-eos
16
15
  Sizes:
@@ -1,26 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Tugboat::CLI do
4
- include_context "spec"
4
+ include_context 'spec'
5
5
 
6
- let(:snapshot_name) { "foo-snapshot" }
6
+ let(:snapshot_name) { 'foo-snapshot' }
7
7
 
8
- describe "snapshots a droplet" do
9
- it "with a fuzzy name" do
10
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
11
- 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.9.2'}).
12
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
8
+ describe 'snapshots a droplet' do
9
+ it 'with a fuzzy name' do
10
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
11
+ 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' }).
12
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
13
13
 
14
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
15
- 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.9.2'}).
16
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
14
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
15
+ 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' }).
16
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
17
17
 
18
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/3164444/actions").
19
- with(:body => "{\"type\":\"snapshot\",\"name\":\"foo-snapshot\"}",
20
- :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.9.2'}).
21
- to_return(:status => 200, :body => fixture('snapshot_response'), :headers => {})
18
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/3164444/actions').
19
+ with(body: '{"type":"snapshot","name":"foo-snapshot"}',
20
+ 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' }).
21
+ to_return(status: 200, body: fixture('snapshot_response'), headers: {})
22
22
 
23
- @cli.snapshot(snapshot_name, 'example3.com')
23
+ cli.snapshot(snapshot_name, 'example3.com')
24
24
 
25
25
  expect($stdout.string).to eq <<-eos
26
26
  Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 3164444 (example3.com)
@@ -29,22 +29,22 @@ Queuing snapshot 'foo-snapshot' for 3164444 (example3.com)...Snapshot successful
29
29
  eos
30
30
  end
31
31
 
32
- it "with an id" do
33
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
34
- 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.9.2'}).
35
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
32
+ it 'with an id' do
33
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
34
+ 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' }).
35
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
36
36
 
37
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/3164444?per_page=200").
38
- 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.9.2'}).
39
- to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_droplet_inactive"))
37
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/3164444?per_page=200').
38
+ 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' }).
39
+ to_return(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_droplet_inactive'))
40
40
 
41
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/3164494/actions").
42
- with(:body => "{\"type\":\"snapshot\",\"name\":\"foo-snapshot\"}",
43
- :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.9.2'}).
44
- to_return(:status => 200, :body => fixture('snapshot_response'), :headers => {})
41
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/3164494/actions').
42
+ with(body: '{"type":"snapshot","name":"foo-snapshot"}',
43
+ 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' }).
44
+ to_return(status: 200, body: fixture('snapshot_response'), headers: {})
45
45
 
46
- @cli.options = @cli.options.merge(:id => '3164444')
47
- @cli.snapshot(snapshot_name)
46
+ cli.options = cli.options.merge(id: '3164444')
47
+ cli.snapshot(snapshot_name)
48
48
 
49
49
  expect($stdout.string).to eq <<-eos
50
50
  Droplet id provided. Finding Droplet...done\e[0m, 3164494 (example.com)
@@ -53,23 +53,22 @@ Queuing snapshot 'foo-snapshot' for 3164494 (example.com)...Snapshot successful!
53
53
  eos
54
54
  end
55
55
 
56
+ it 'with a name' do
57
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
58
+ 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' }).
59
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
56
60
 
57
- it "with a name" 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.9.2'}).
60
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
61
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
62
+ 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' }).
63
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
61
64
 
62
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&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.9.2'}).
64
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
65
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/3164444/actions').
66
+ with(body: '{"type":"snapshot","name":"foo-snapshot"}',
67
+ 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' }).
68
+ to_return(status: 200, body: fixture('snapshot_response'), headers: {})
65
69
 
66
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/3164444/actions").
67
- with(:body => "{\"type\":\"snapshot\",\"name\":\"foo-snapshot\"}",
68
- :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.9.2'}).
69
- to_return(:status => 200, :body => fixture('snapshot_response'), :headers => {})
70
-
71
- @cli.options = @cli.options.merge(:name => 'example3.com')
72
- @cli.snapshot(snapshot_name)
70
+ cli.options = cli.options.merge(name: 'example3.com')
71
+ cli.snapshot(snapshot_name)
73
72
 
74
73
  expect($stdout.string).to eq <<-eos
75
74
  Droplet name provided. Finding droplet ID...done\e[0m, 3164444 (example3.com)
@@ -78,24 +77,22 @@ Queuing snapshot 'foo-snapshot' for 3164444 (example3.com)...Snapshot successful
78
77
  eos
79
78
  end
80
79
 
81
- it "does not snapshot a droplet that is active" do
82
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
83
- 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.9.2'}).
84
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
80
+ it 'does not snapshot a droplet that is active' do
81
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
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_droplets'), headers: {})
85
84
 
86
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
87
- 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.9.2'}).
88
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
85
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
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
- @cli.options = @cli.options.merge(:name => 'example.com')
91
- expect {@cli.snapshot(snapshot_name)}.to raise_error(SystemExit)
89
+ cli.options = cli.options.merge(name: 'example.com')
90
+ expect { cli.snapshot(snapshot_name) }.to raise_error(SystemExit)
92
91
 
93
92
  expect($stdout.string).to eq <<-eos
94
93
  Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
95
94
  Droplet must be off for this operation to be successful.
96
95
  eos
97
96
  end
98
-
99
97
  end
100
-
101
98
  end