tugboat 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
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,12 +1,11 @@
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 "config" do
7
- it "shows the full config" do
8
-
9
- @cli.config
6
+ describe 'config' do
7
+ it 'shows the full config' do
8
+ cli.config
10
9
 
11
10
  expect($stdout.string).to eq <<-eos
12
11
  Current Config\x20
@@ -29,12 +28,11 @@ defaults:
29
28
  eos
30
29
  end
31
30
 
32
- it "hides sensitive data if option given" do
33
-
34
- @cli.options = @cli.options.merge(:hide => true)
35
- @cli.config
31
+ it 'hides sensitive data if option given' do
32
+ cli.options = cli.options.merge(hide: true)
33
+ cli.config
36
34
 
37
- expect($stdout.string).to eq <<-eos
35
+ expect($stdout.string).to eq <<-eos
38
36
  Current Config (Keys Redacted)
39
37
  Path: #{Dir.pwd}/tmp/tugboat
40
38
  ---
@@ -56,4 +54,3 @@ defaults:
56
54
  end
57
55
  end
58
56
  end
59
-
@@ -1,82 +1,76 @@
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 "create a droplet" do
7
- it "with a name, uses defaults from configuration" do
8
- stub_request(:post, "https://api.digitalocean.com/v2/droplets").
9
- with(:body => "{\"name\":\"foo\",\"size\":\"512mb\",\"image\":\"ubuntu-14-04-x64\",\"region\":\"nyc2\",\"ssh_keys\":[\"1234\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\":\"false\",\"user_data\":null}",
10
- :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(:status => 200, :body => fixture('create_droplet'), :headers => {})
6
+ describe 'create a droplet' do
7
+ it 'with a name, uses defaults from configuration' do
8
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets').
9
+ with(body: '{"name":"foo","size":"512mb","image":"ubuntu-14-04-x64","region":"nyc2","ssh_keys":["1234"],"private_networking":"false","backups_enabled":"false","ipv6":"false","user_data":null}',
10
+ 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' }).
11
+ to_return(status: 200, body: fixture('create_droplet'), headers: {})
12
12
 
13
- @cli.create(droplet_name)
13
+ cli.create(droplet_name)
14
14
 
15
15
  expect($stdout.string).to eq <<-eos
16
16
  Queueing creation of droplet '#{droplet_name}'...Droplet created!
17
17
  eos
18
18
  end
19
19
 
20
- it "with args does not use defaults from configuration" do
21
- stub_request(:post, "https://api.digitalocean.com/v2/droplets").
22
- with(:body => "{\"name\":\"example.com\",\"size\":\"1gb\",\"image\":\"ubuntu-12-04-x64\",\"region\":\"nyc3\",\"ssh_keys\":[\"foo_bar_key\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\":\"false\",\"user_data\":null}",
23
- :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'}).
24
- to_return(:status => 200, :body => fixture('create_droplet'), :headers => {})
20
+ it 'with args does not use defaults from configuration' do
21
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets').
22
+ with(body: '{"name":"example.com","size":"1gb","image":"ubuntu-12-04-x64","region":"nyc3","ssh_keys":["foo_bar_key"],"private_networking":"false","backups_enabled":"false","ipv6":"false","user_data":null}',
23
+ 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' }).
24
+ to_return(status: 200, body: fixture('create_droplet'), headers: {})
25
25
 
26
- @cli.options = @cli.options.merge(:image => 'ubuntu-12-04-x64', :size => '1gb', :region => 'nyc3', :keys => 'foo_bar_key')
27
- @cli.create('example.com')
26
+ cli.options = cli.options.merge(image: 'ubuntu-12-04-x64', size: '1gb', region: 'nyc3', keys: 'foo_bar_key')
27
+ cli.create('example.com')
28
28
 
29
29
  expect($stdout.string).to eq <<-eos
30
30
  Queueing creation of droplet 'example.com'...Droplet created!
31
31
  eos
32
-
33
32
  end
34
33
 
35
- it "with ip6 enable args" do
36
- stub_request(:post, "https://api.digitalocean.com/v2/droplets").
37
- with(:body => "{\"name\":\"example.com\",\"size\":\"512mb\",\"image\":\"ubuntu-14-04-x64\",\"region\":\"nyc2\",\"ssh_keys\":[\"1234\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\":\"true\",\"user_data\":null}",
38
- :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(:status => 200, :body => fixture('create_droplet'), :headers => {})
34
+ it 'with ip6 enable args' do
35
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets').
36
+ with(body: '{"name":"example.com","size":"512mb","image":"ubuntu-14-04-x64","region":"nyc2","ssh_keys":["1234"],"private_networking":"false","backups_enabled":"false","ipv6":"true","user_data":null}',
37
+ 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('create_droplet'), headers: {})
40
39
 
41
- @cli.options = @cli.options.merge(:ip6 => 'true')
42
- @cli.create('example.com')
40
+ cli.options = cli.options.merge(ip6: 'true')
41
+ cli.create('example.com')
43
42
 
44
43
  expect($stdout.string).to eq <<-eos
45
44
  Queueing creation of droplet 'example.com'...Droplet created!
46
45
  eos
47
-
48
46
  end
49
47
 
50
- it "with user data args" do
51
- stub_request(:post, "https://api.digitalocean.com/v2/droplets").
52
- with(:body => "{\"name\":\"example.com\",\"size\":\"512mb\",\"image\":\"ubuntu-14-04-x64\",\"region\":\"nyc2\",\"ssh_keys\":[\"1234\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\":\"false\",\"user_data\":\"#!/bin/bash\\n\\necho \\\"Hello world\\\"\"}",
53
- :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'}).
54
- to_return(:status => 200, :body => fixture('create_droplet'), :headers => {})
48
+ it 'with user data args' do
49
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets').
50
+ with(body: '{"name":"example.com","size":"512mb","image":"ubuntu-14-04-x64","region":"nyc2","ssh_keys":["1234"],"private_networking":"false","backups_enabled":"false","ipv6":"false","user_data":"#!/bin/bash\\n\\necho \\"Hello world\\""}',
51
+ 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' }).
52
+ to_return(status: 200, body: fixture('create_droplet'), headers: {})
55
53
 
56
- @cli.options = @cli.options.merge(:user_data => project_path + "/spec/fixtures/user_data.sh")
57
- @cli.create('example.com')
54
+ cli.options = cli.options.merge(user_data: project_path + '/spec/fixtures/user_data.sh')
55
+ cli.create('example.com')
58
56
 
59
57
  expect($stdout.string).to eq <<-eos
60
58
  Queueing creation of droplet 'example.com'...Droplet created!
61
59
  eos
62
-
63
60
  end
64
61
 
65
- it "fails when user data file does not exist" do
66
- @cli.options = @cli.options.merge(:user_data => "/foo/bar/baz.sh")
67
- expect {@cli.create("example.com")}.to raise_error(SystemExit)
62
+ it 'fails when user data file does not exist' do
63
+ cli.options = cli.options.merge(user_data: '/foo/bar/baz.sh')
64
+ expect { cli.create('example.com') }.to raise_error(SystemExit)
68
65
 
69
66
  expect($stdout.string).to eq <<-eos
70
67
  Queueing creation of droplet 'example.com'...Could not find file: /foo/bar/baz.sh, check your user_data setting
71
68
  eos
72
-
73
69
  end
74
70
 
75
71
  context "doesn't create a droplet when mistyping help command" do
76
-
77
- ['help','--help','-h'].each do |help_attempt|
72
+ ['help', '--help', '-h'].each do |help_attempt|
78
73
  it "tugboat create #{help_attempt}" do
79
-
80
74
  help_text = <<-eos
81
75
  Usage:
82
76
  rspec create NAME
@@ -95,19 +89,19 @@ Options:
95
89
  Create a droplet.
96
90
  eos
97
91
 
98
- @cli.create(help_attempt)
92
+ cli.create(help_attempt)
99
93
  expect($stdout.string).to eq help_text
100
94
  end
101
95
  end
102
96
  end
103
97
 
104
- it "does not clobber named droplets that contain the word help" do
105
- stub_request(:post, "https://api.digitalocean.com/v2/droplets").
106
- with(:body => "{\"name\":\"somethingblahblah--help\",\"size\":\"512mb\",\"image\":\"ubuntu-14-04-x64\",\"region\":\"nyc2\",\"ssh_keys\":[\"1234\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\":\"false\",\"user_data\":null}",
107
- :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'}).
108
- to_return(:status => 200, :body => fixture('create_droplet'), :headers => {})
98
+ it 'does not clobber named droplets that contain the word help' do
99
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets').
100
+ with(body: '{"name":"somethingblahblah--help","size":"512mb","image":"ubuntu-14-04-x64","region":"nyc2","ssh_keys":["1234"],"private_networking":"false","backups_enabled":"false","ipv6":"false","user_data":null}',
101
+ 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' }).
102
+ to_return(status: 200, body: fixture('create_droplet'), headers: {})
109
103
 
110
- @cli.create('somethingblahblah--help')
104
+ cli.create('somethingblahblah--help')
111
105
 
112
106
  expect($stdout.string).to eq <<-eos
113
107
  Queueing creation of droplet 'somethingblahblah--help'...Droplet created!
@@ -1,58 +1,58 @@
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 "DEBUG=1" do
7
- before(:each) do
6
+ describe 'DEBUG=1' do
7
+ before do
8
8
  allow(ENV).to receive(:[]).with('HOME').and_return('/tmp/fake_home')
9
9
  allow(ENV).to receive(:[]).with('DEBUG').and_return(1)
10
10
  allow(ENV).to receive(:[]).with('http_proxy').and_return(nil)
11
11
  allow(ENV).to receive(:[]).with('DO_API_TOKEN').and_return(nil)
12
+ allow(ENV).to receive(:[]).with('THOR_SHELL').and_return(nil)
12
13
  end
13
14
 
14
- it "gives full faraday logs" do
15
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
16
- 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'}).
17
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
15
+ it 'gives full faraday logs' do
16
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
17
+ 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' }).
18
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
18
19
 
19
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
20
- 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'}).
21
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
20
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
21
+ 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' }).
22
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
22
23
 
23
- @cli.droplets
24
+ cli.droplets
24
25
 
25
- expect($stdout.string).to include "Started GET request to: https://api.digitalocean.com/v2/droplets?page=1&per_page=200"
26
- expect($stdout.string).to include "DEBUG -- : Request Headers:"
26
+ expect($stdout.string).to include 'Started GET request to: https://api.digitalocean.com/v2/droplets?page=1&per_page=200'
27
+ expect($stdout.string).to include 'DEBUG -- : Request Headers:'
27
28
 
28
- expect($stdout.string).to include "Bearer foo"
29
+ expect($stdout.string).to include 'Bearer foo'
29
30
  end
30
31
  end
31
32
 
32
- describe "DEBUG=2" do
33
- before(:each) do
33
+ describe 'DEBUG=2' do
34
+ before do
34
35
  allow(ENV).to receive(:[]).with('HOME').and_return('/tmp/fake_home')
35
36
  allow(ENV).to receive(:[]).with('DEBUG').and_return(2)
36
37
  allow(ENV).to receive(:[]).with('http_proxy').and_return(nil)
37
38
  allow(ENV).to receive(:[]).with('DO_API_TOKEN').and_return(nil)
39
+ allow(ENV).to receive(:[]).with('THOR_SHELL').and_return(nil)
38
40
  end
39
41
 
40
- it "gives full faraday logs with redacted API keys" do
41
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
42
- 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'}).
43
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
42
+ it 'gives full faraday logs with redacted API keys' do
43
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
44
+ 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' }).
45
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
44
46
 
45
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
46
- 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'}).
47
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
48
- @cli.droplets
47
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
48
+ 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' }).
49
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
50
+ cli.droplets
49
51
 
50
- expect($stdout.string).to include "Started GET request to: https://api.digitalocean.com/v2/droplets?page=1&per_page=200"
51
- expect($stdout.string).to include "DEBUG -- : Request Headers:"
52
+ expect($stdout.string).to include 'Started GET request to: https://api.digitalocean.com/v2/droplets?page=1&per_page=200'
53
+ expect($stdout.string).to include 'DEBUG -- : Request Headers:'
52
54
 
53
- expect($stdout.string).to_not include "Bearer foo"
55
+ expect($stdout.string).not_to include 'Bearer foo'
54
56
  end
55
57
  end
56
-
57
58
  end
58
-
@@ -1,89 +1,88 @@
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 "destroy" do
7
- it "destroys 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 'destroy' do
7
+ it 'destroys 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(:delete, "https://api.digitalocean.com/v2/droplets/6918990").
17
- 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'}).
18
- to_return(:status => 204, :body => "", :headers => {})
16
+ stub_request(:delete, 'https://api.digitalocean.com/v2/droplets/6918990').
17
+ 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' }).
18
+ to_return(status: 204, body: '', headers: {})
19
19
 
20
- expect($stdin).to receive(:gets).and_return("y")
20
+ expect($stdin).to receive(:gets).and_return('y')
21
21
 
22
- @cli.destroy("example.com")
22
+ cli.destroy('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)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy for 6918990 (example.com)...Deletion Successful!
26
26
  eos
27
27
  end
28
28
 
29
- it "destroys a droplet with an id" do
30
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
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.9.2'}).
32
- to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
29
+ it 'destroys a droplet with an id' do
30
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
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_droplet'), headers: {})
33
33
 
34
- stub_request(:delete, "https://api.digitalocean.com/v2/droplets/6918990").
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.9.2'}).
36
- to_return(:status => 204, :body => "", :headers => {})
34
+ stub_request(:delete, 'https://api.digitalocean.com/v2/droplets/6918990').
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: 204, body: '', headers: {})
37
37
 
38
- expect($stdin).to receive(:gets).and_return("y")
38
+ expect($stdin).to receive(:gets).and_return('y')
39
39
 
40
- @cli.options = @cli.options.merge(:id => '6918990')
41
- @cli.destroy
40
+ cli.options = cli.options.merge(id: '6918990')
41
+ cli.destroy
42
42
 
43
43
  expect($stdout.string).to eq <<-eos
44
44
  Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy for 6918990 (example.com)...Deletion Successful!
45
45
  eos
46
46
  end
47
47
 
48
+ it 'destroys a droplet with a name' do
49
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
50
+ 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' }).
51
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
48
52
 
49
- it "destroys a droplet with a name" do
50
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
51
- 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'}).
52
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
53
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
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: {})
53
56
 
54
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
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 => {})
57
+ stub_request(:delete, 'https://api.digitalocean.com/v2/droplets/6918990').
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: 204, body: '', headers: {})
57
60
 
58
- stub_request(:delete, "https://api.digitalocean.com/v2/droplets/6918990").
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 => 204, :body => "", :headers => {})
61
+ expect($stdin).to receive(:gets).and_return('y')
61
62
 
62
- expect($stdin).to receive(:gets).and_return("y")
63
-
64
- @cli.options = @cli.options.merge(:name => 'example.com')
65
- @cli.destroy
63
+ cli.options = cli.options.merge(name: 'example.com')
64
+ cli.destroy
66
65
 
67
66
  expect($stdout.string).to eq <<-eos
68
67
  Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy for 6918990 (example.com)...Deletion Successful!
69
68
  eos
70
69
  end
71
70
 
72
- it "destroys a droplet with confirm flag set" do
73
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
74
- 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'}).
75
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
71
+ it 'destroys a droplet with confirm flag set' do
72
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
73
+ 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' }).
74
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
76
75
 
77
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&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.9.2'}).
79
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
76
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
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: {})
80
79
 
81
- stub_request(:delete, "https://api.digitalocean.com/v2/droplets/6918990").
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.9.2'}).
83
- to_return(:status => 204, :body => "", :headers => {})
80
+ stub_request(:delete, 'https://api.digitalocean.com/v2/droplets/6918990').
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: 204, body: '', headers: {})
84
83
 
85
- @cli.options = @cli.options.merge(:name => 'example.com', :confirm => true)
86
- @cli.destroy
84
+ cli.options = cli.options.merge(name: 'example.com', confirm: true)
85
+ cli.destroy
87
86
 
88
87
  expect($stdout.string).to eq <<-eos
89
88
  Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
@@ -91,23 +90,22 @@ Queuing destroy for 6918990 (example.com)...Deletion Successful!
91
90
  eos
92
91
  end
93
92
 
94
- it "does not destroy a droplet if no is chosen" do
95
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
96
- 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'}).
97
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
93
+ it 'does not destroy a droplet if no is chosen' do
94
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
95
+ 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' }).
96
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
98
97
 
99
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
100
- 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'}).
101
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
98
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
99
+ 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' }).
100
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
102
101
 
103
- $stdin.should_receive(:gets).and_return("n")
102
+ $stdin.should_receive(:gets).and_return('n')
104
103
 
105
- expect {@cli.destroy("example.com")}.to raise_error(SystemExit)
104
+ expect { cli.destroy('example.com') }.to raise_error(SystemExit)
106
105
 
107
106
  expect($stdout.string).to eq <<-eos
108
107
  Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)\nWarning! Potentially destructive action. Please confirm [y/n]: Aborted due to user request.
109
108
  eos
110
109
  end
111
110
  end
112
-
113
111
  end
@@ -1,82 +1,79 @@
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 "destroy image" do
7
- it "destroys an image with a fuzzy name" 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.9.2'}).
10
- to_return(:status => 200, :body => fixture('show_images_global'), :headers => {})
6
+ describe 'destroy image' do
7
+ it 'destroys an image with a fuzzy name' 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_global'), headers: {})
11
11
 
12
- stub_request(:delete, "https://api.digitalocean.com/v2/images/6376601").
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 => 204, :body => "", :headers => {})
12
+ stub_request(:delete, 'https://api.digitalocean.com/v2/images/6376601').
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: 204, body: '', headers: {})
15
15
 
16
- expect($stdin).to receive(:gets).and_return("y")
16
+ expect($stdin).to receive(:gets).and_return('y')
17
17
 
18
- @cli.destroy_image("My application image")
18
+ cli.destroy_image('My application image')
19
19
 
20
20
  expect($stdout.string).to eq <<-eos
21
21
  Image fuzzy name provided. Finding image ID...done\e[0m, 6376601 (My application image)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy image for 6376601 (My application image)...Image deletion successful!
22
22
  eos
23
23
  end
24
24
 
25
- it "destroys an image with an id" do
26
- stub_request(:get, "https://api.digitalocean.com/v2/images/6376601?per_page=200").
27
- 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'}).
28
- to_return(:status => 200, :body => fixture('show_image'), :headers => {})
25
+ it 'destroys an image with an id' do
26
+ stub_request(:get, 'https://api.digitalocean.com/v2/images/6376601?per_page=200').
27
+ 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' }).
28
+ to_return(status: 200, body: fixture('show_image'), headers: {})
29
29
 
30
- stub_request(:delete, "https://api.digitalocean.com/v2/images/6376601").
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.9.2'}).
32
- to_return(:status => 204, :body => "", :headers => {})
30
+ stub_request(:delete, 'https://api.digitalocean.com/v2/images/6376601').
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: 204, body: '', headers: {})
33
33
 
34
- expect($stdin).to receive(:gets).and_return("y")
34
+ expect($stdin).to receive(:gets).and_return('y')
35
35
 
36
- @cli.options = @cli.options.merge(:id => 6376601)
37
- @cli.destroy_image
36
+ cli.options = cli.options.merge(id: 6_376_601)
37
+ cli.destroy_image
38
38
 
39
39
  expect($stdout.string).to eq <<-eos
40
40
  Image id provided. Finding Image...done\e[0m, 6376601 (My application image)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy image for 6376601 (My application image)...Image deletion successful!
41
41
  eos
42
- end
43
-
42
+ end
44
43
 
45
- it "destroys an image with a name" do
46
- stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
47
- 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'}).
48
- to_return(:status => 200, :body => fixture('show_images_global'), :headers => {})
44
+ it 'destroys an image with a name' do
45
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
46
+ 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' }).
47
+ to_return(status: 200, body: fixture('show_images_global'), headers: {})
49
48
 
50
- stub_request(:delete, "https://api.digitalocean.com/v2/images/6376601").
51
- 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'}).
52
- to_return(:status => 204, :body => "", :headers => {})
49
+ stub_request(:delete, 'https://api.digitalocean.com/v2/images/6376601').
50
+ 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' }).
51
+ to_return(status: 204, body: '', headers: {})
53
52
 
54
- expect($stdin).to receive(:gets).and_return("y")
53
+ expect($stdin).to receive(:gets).and_return('y')
55
54
 
56
- @cli.options = @cli.options.merge(:name => "My application image")
57
- @cli.destroy_image
55
+ cli.options = cli.options.merge(name: 'My application image')
56
+ cli.destroy_image
58
57
 
59
58
  expect($stdout.string).to eq "Image name provided. Finding Image...done\e[0m, 6376601 (My application image)\nWarning! Potentially destructive action. Please confirm [y/n]: Queuing destroy image for 6376601 (My application image)...Image deletion successful!\n"
60
59
  end
61
60
 
61
+ it 'destroys an image with confirm flag set' do
62
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?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_images_global'), headers: {})
62
65
 
63
- it "destroys an image with confirm flag set" do
64
- stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
65
- 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'}).
66
- to_return(:status => 200, :body => fixture('show_images_global'), :headers => {})
66
+ stub_request(:delete, 'https://api.digitalocean.com/v2/images/6376601').
67
+ 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' }).
68
+ to_return(status: 204, body: '', headers: {})
67
69
 
68
- stub_request(:delete, "https://api.digitalocean.com/v2/images/6376601").
69
- 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'}).
70
- to_return(:status => 204, :body => "", :headers => {})
71
-
72
- @cli.options = @cli.options.merge(:name => "My application image")
73
- @cli.options = @cli.options.merge(:confirm => true)
74
- @cli.destroy_image("NLP Final")
70
+ cli.options = cli.options.merge(name: 'My application image')
71
+ cli.options = cli.options.merge(confirm: true)
72
+ cli.destroy_image('NLP Final')
75
73
 
76
74
  expect($stdout.string).to eq <<-eos
77
75
  Image name provided. Finding Image...done\e[0m, 6376601 (My application image)\nQueuing destroy image for 6376601 (My application image)...Image deletion successful!
78
76
  eos
79
77
  end
80
78
  end
81
-
82
79
  end