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,19 +1,19 @@
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 "droplets" do
7
- it "shows a list when droplets exist" 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 'droplets' do
7
+ it 'shows a list when droplets exist' 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 => {'Content-Type' => 'application/json'},)
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: { 'Content-Type' => 'application/json' })
15
15
 
16
- @cli.droplets
16
+ cli.droplets
17
17
 
18
18
  expect($stdout.string).to eq <<-eos
19
19
  example.com (ip: 104.236.32.182, status: \e[32mactive\e[0m, region: nyc3, id: 6918990)
@@ -21,19 +21,19 @@ example2.com (ip: 104.236.32.172, status: \e[32mactive\e[0m, region: nyc3, id: 3
21
21
  example3.com (ip: 104.236.32.173, status: \e[31moff\e[0m, region: nyc3, id: 3164444)
22
22
  eos
23
23
 
24
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200")).to have_been_made
24
+ expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200')).to have_been_made
25
25
  end
26
26
 
27
- it "shows a private IP if droplet in list has private IP" 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.9.2'}).
30
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
27
+ it 'shows a private IP if droplet in list has private IP' 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, "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.9.2'}).
34
- to_return(:status => 200, :body => fixture("show_droplets_private_ip"), :headers => {'Content-Type' => 'application/json'},)
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_private_ip'), headers: { 'Content-Type' => 'application/json' })
35
35
 
36
- @cli.droplets
36
+ cli.droplets
37
37
 
38
38
  expect($stdout.string).to eq <<-eos
39
39
  exampleprivate.com (ip: 104.236.32.182, private_ip: 10.131.99.89, status: \e[32mactive\e[0m, region: nyc3, id: 6918990)
@@ -41,57 +41,57 @@ example2.com (ip: 104.236.32.172, status: \e[32mactive\e[0m, region: nyc3, id: 3
41
41
  example3.com (ip: 104.236.32.173, status: \e[31moff\e[0m, region: nyc3, id: 3164444)
42
42
  eos
43
43
 
44
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200")).to have_been_made
44
+ expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200')).to have_been_made
45
45
  end
46
46
 
47
- it "returns an error message when no droplets exist" do
48
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
49
- 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'}).
50
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
47
+ it 'returns an error message when no droplets exist' do
48
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
49
+ 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' }).
50
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
51
51
 
52
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
53
- 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'}).
54
- to_return(:status => 200, :body => fixture("show_droplets_empty"), :headers => {'Content-Type' => 'application/json'},)
52
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
53
+ 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' }).
54
+ to_return(status: 200, body: fixture('show_droplets_empty'), headers: { 'Content-Type' => 'application/json' })
55
55
 
56
- @cli.droplets
56
+ cli.droplets
57
57
 
58
58
  expect($stdout.string).to eq <<-eos
59
59
  You don't appear to have any droplets.
60
60
  Try creating one with \e[32m`tugboat create`\e[0m
61
61
  eos
62
62
 
63
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200")).to have_been_made
63
+ expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200')).to have_been_made
64
64
  end
65
65
 
66
- it "shows no output when --quiet is set" do
67
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
68
- 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'}).
69
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
66
+ it 'shows no output when --quiet is set' do
67
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
68
+ 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' }).
69
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
70
70
 
71
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
72
- 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'}).
73
- to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
71
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
72
+ 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' }).
73
+ to_return(status: 200, body: fixture('show_droplets'), headers: { 'Content-Type' => 'application/json' })
74
74
 
75
- @cli.options = @cli.options.merge(:quiet => true)
76
- @cli.droplets
75
+ cli.options = cli.options.merge(quiet: true)
76
+ cli.droplets
77
77
 
78
78
  # Should be /dev/null not stringIO
79
79
  expect($stdout).to be_a File
80
80
 
81
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200")).to have_been_made
81
+ expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200')).to have_been_made
82
82
  end
83
83
 
84
- it "includes urls when --include-urls is set" 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.9.2'}).
87
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
84
+ it 'includes urls when --include-urls is set' 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: {})
88
88
 
89
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&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.9.2'}).
91
- to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
89
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&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_droplets'), headers: { 'Content-Type' => 'application/json' })
92
92
 
93
- @cli.options = @cli.options.merge("include_urls" => true)
94
- @cli.droplets
93
+ cli.options = cli.options.merge('include_urls' => true)
94
+ cli.droplets
95
95
 
96
96
  expect($stdout.string).to eq <<-eos
97
97
  example.com (ip: 104.236.32.182, status: \e[32mactive\e[0m, region: nyc3, id: 6918990, url: 'https://cloud.digitalocean.com/droplets/6918990')
@@ -99,24 +99,24 @@ example2.com (ip: 104.236.32.172, status: \e[32mactive\e[0m, region: nyc3, id: 3
99
99
  example3.com (ip: 104.236.32.173, status: \e[31moff\e[0m, region: nyc3, id: 3164444, url: 'https://cloud.digitalocean.com/droplets/3164444')
100
100
  eos
101
101
 
102
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200")).to have_been_made
102
+ expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200')).to have_been_made
103
103
  end
104
104
 
105
- it "paginates when multiple pages are returned" do
106
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
107
- 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'}).
108
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
105
+ it 'paginates when multiple pages are returned' do
106
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
107
+ 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' }).
108
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
109
109
 
110
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
111
- 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'}).
112
- to_return(:status => 200, :body => fixture("show_droplets_paginated_first"), :headers => {'Content-Type' => 'application/json'},)
110
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
111
+ 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' }).
112
+ to_return(status: 200, body: fixture('show_droplets_paginated_first'), headers: { 'Content-Type' => 'application/json' })
113
113
 
114
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=2&per_page=200").
115
- 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'}).
116
- to_return(:status => 200, :body => fixture("show_droplets_paginated_last"), :headers => {'Content-Type' => 'application/json'},)
114
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=2&per_page=200').
115
+ 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' }).
116
+ to_return(status: 200, body: fixture('show_droplets_paginated_last'), headers: { 'Content-Type' => 'application/json' })
117
117
 
118
- @cli.options = @cli.options.merge("include_urls" => true)
119
- @cli.droplets
118
+ cli.options = cli.options.merge('include_urls' => true)
119
+ cli.droplets
120
120
 
121
121
  expect($stdout.string).to eq <<-eos
122
122
  page1example.com (ip: 104.236.32.182, status: \e[32mactive\e[0m, region: nyc3, id: 6918990, url: 'https://cloud.digitalocean.com/droplets/6918990')
@@ -127,9 +127,7 @@ page2example2.com (ip: 104.236.32.172, status: \e[32mactive\e[0m, region: nyc3,
127
127
  page2example3.com (ip: 104.236.32.173, status: \e[31moff\e[0m, region: nyc3, id: 3164444, url: 'https://cloud.digitalocean.com/droplets/3164444')
128
128
  eos
129
129
 
130
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200")).to have_been_made
130
+ expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200')).to have_been_made
131
131
  end
132
132
  end
133
-
134
133
  end
135
-
@@ -1,38 +1,37 @@
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 "DO_API_TOKEN=foobar" do
7
- it "verifies with the ENV variable DO_API_TOKEN" 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 env_variable', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
10
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
6
+ describe 'DO_API_TOKEN=foobar' do
7
+ it 'verifies with the ENV variable DO_API_TOKEN' 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 env_variable', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
10
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
11
11
 
12
12
  allow(ENV).to receive(:[]).with('HOME').and_return('/tmp/fake_home')
13
13
  allow(ENV).to receive(:[]).with('DO_API_TOKEN').and_return('env_variable')
14
14
  allow(ENV).to receive(:[]).with('http_proxy').and_return(nil)
15
15
  allow(ENV).to receive(:[]).with('DEBUG').and_return(nil)
16
16
 
17
- @cli.verify
17
+ cli.verify
18
18
  expect($stdout.string).to eq "Authentication with DigitalOcean was successful.\n"
19
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1")).to have_been_made
19
+ expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1')).to have_been_made
20
20
  end
21
21
 
22
- it "does not use ENV variable DO_API_TOKEN if empty" do
23
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
24
- 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'}).
25
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
22
+ it 'does not use ENV variable DO_API_TOKEN if empty' do
23
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
24
+ 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' }).
25
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
26
26
 
27
27
  allow(ENV).to receive(:[]).with('HOME').and_return('/tmp/fake_home')
28
28
  allow(ENV).to receive(:[]).with('DO_API_TOKEN').and_return('')
29
29
  allow(ENV).to receive(:[]).with('http_proxy').and_return(nil)
30
30
  allow(ENV).to receive(:[]).with('DEBUG').and_return(nil)
31
31
 
32
- @cli.verify
32
+ cli.verify
33
33
  expect($stdout.string).to eq "Authentication with DigitalOcean was successful.\n"
34
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1")).to have_been_made
34
+ expect(a_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1')).to have_been_made
35
35
  end
36
36
  end
37
37
  end
38
-
@@ -1,24 +1,24 @@
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 "halt" do
7
- it "halts 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 'halt' do
7
+ it 'halts 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\":\"shutdown\"}",
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('shutdown_response'), :headers => {})
16
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
17
+ with(body: '{"type":"shutdown"}',
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('shutdown_response'), headers: {})
20
20
 
21
- @cli.halt("example.com")
21
+ cli.halt('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)
@@ -26,22 +26,22 @@ Queuing shutdown for 6918990 (example.com)...Halt successful!
26
26
  eos
27
27
  end
28
28
 
29
- it "halts 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.9.2'}).
32
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
29
+ it 'halts 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: {})
33
33
 
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.9.2'}).
36
- 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: {})
37
37
 
38
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
39
- with(:body => "{\"type\":\"power_off\"}",
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.9.2'}).
41
- to_return(:status => 200, :body => "", :headers => {})
38
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
39
+ with(body: '{"type":"power_off"}',
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: {})
42
42
 
43
- @cli.options = @cli.options.merge(:hard => true)
44
- @cli.halt("example.com")
43
+ cli.options = cli.options.merge(hard: true)
44
+ cli.halt('example.com')
45
45
 
46
46
  expect($stdout.string).to eq <<-eos
47
47
  Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
@@ -49,26 +49,26 @@ Queuing hard shutdown for 6918990 (example.com)...Halt successful!
49
49
  eos
50
50
  end
51
51
 
52
- it "halts a droplet 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.9.2'}).
55
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
52
+ it 'halts a droplet 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: {})
56
56
 
57
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/?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.9.2'}).
59
- to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
57
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/?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_droplets'), headers: { 'Content-Type' => 'application/json' })
60
60
 
61
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?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.9.2'}).
63
- to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
61
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?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_droplet'), headers: {})
64
64
 
65
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
66
- with(:body => "{\"type\":\"shutdown\"}",
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.9.2'}).
68
- to_return(:status => 200, :body => fixture('shutdown_response'), :headers => {})
65
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
66
+ with(body: '{"type":"shutdown"}',
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('shutdown_response'), headers: {})
69
69
 
70
- @cli.options = @cli.options.merge(:id => '6918990')
71
- @cli.halt
70
+ cli.options = cli.options.merge(id: '6918990')
71
+ cli.halt
72
72
 
73
73
  expect($stdout.string).to eq <<-eos
74
74
  Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
@@ -76,23 +76,22 @@ Queuing shutdown for 6918990 (example.com)...Halt successful!
76
76
  eos
77
77
  end
78
78
 
79
+ it 'halts a droplet with a name' do
80
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
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: {})
79
83
 
80
- it "halts a droplet with a name" 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.9.2'}).
83
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
84
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
85
+ 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' }).
86
+ to_return(status: 200, body: fixture('show_droplets'), headers: { 'Content-Type' => 'application/json' })
84
87
 
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.9.2'}).
87
- to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
88
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
89
+ with(body: '{"type":"shutdown"}',
90
+ 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('shutdown_response'), headers: {})
88
92
 
89
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
90
- with(:body => "{\"type\":\"shutdown\"}",
91
- :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'}).
92
- to_return(:status => 200, :body => fixture('shutdown_response'), :headers => {})
93
-
94
- @cli.options = @cli.options.merge(:name => 'example.com')
95
- @cli.halt
93
+ cli.options = cli.options.merge(name: 'example.com')
94
+ cli.halt
96
95
 
97
96
  expect($stdout.string).to eq <<-eos
98
97
  Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
@@ -100,25 +99,22 @@ Queuing shutdown for 6918990 (example.com)...Halt successful!
100
99
  eos
101
100
  end
102
101
 
102
+ it 'does not halt a droplet that is off' do
103
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
104
+ 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' }).
105
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
103
106
 
104
- it "does not halt a droplet that is off" do
105
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
106
- 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'}).
107
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
108
-
109
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
110
- 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'}).
111
- to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
107
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
108
+ 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' }).
109
+ to_return(status: 200, body: fixture('show_droplets'), headers: { 'Content-Type' => 'application/json' })
112
110
 
113
- @cli.options = @cli.options.merge(:name => 'example3.com')
114
- expect {@cli.halt}.to raise_error(SystemExit)
111
+ cli.options = cli.options.merge(name: 'example3.com')
112
+ expect { cli.halt }.to raise_error(SystemExit)
115
113
 
116
114
  expect($stdout.string).to eq <<-eos
117
115
  Droplet name provided. Finding droplet ID...done\e[0m, 3164444 (example3.com)
118
116
  Droplet must be on for this operation to be successful.
119
117
  eos
120
118
  end
121
-
122
119
  end
123
-
124
120
  end
@@ -1,17 +1,17 @@
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 "help" do
7
- it "shows a help message" do
8
- @cli.help
9
- expect($stdout.string).to match("Commands:")
6
+ describe 'help' do
7
+ it 'shows a help message' do
8
+ cli.help
9
+ expect($stdout.string).to match('Commands:')
10
10
  end
11
11
 
12
- it "shows a help message for specific commands" do
13
- @cli.help "sizes"
14
- expect($stdout.string).to match("Usage:")
12
+ it 'shows a help message for specific commands' do
13
+ cli.help 'sizes'
14
+ expect($stdout.string).to match('Usage:')
15
15
  end
16
16
  end
17
17
  end