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 "info_image" do
7
- it "shows 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(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
6
+ describe 'info_image' do
7
+ it 'shows 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(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_images'))
11
11
 
12
- stub_request(:get, "https://api.digitalocean.com/v2/images/12789325?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(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_coreos_image"))
12
+ stub_request(:get, 'https://api.digitalocean.com/v2/images/12789325?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(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_coreos_image'))
15
15
 
16
- @cli.info_image("745.1.0 (alpha)")
16
+ cli.info_image('745.1.0 (alpha)')
17
17
 
18
18
  expect($stdout.string).to eq <<-eos
19
19
  Image fuzzy name provided. Finding image ID...done\e[0m, 12789325 (745.1.0 (alpha))
@@ -26,17 +26,17 @@ Regions: nyc1,sfo1,nyc2,ams2,sgp1,lon1,nyc3,ams3,fra1
26
26
  eos
27
27
  end
28
28
 
29
- it "shows an image with an id" do
30
- stub_request(:get, "https://api.digitalocean.com/v2/images?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(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
29
+ it 'shows an image with an id' do
30
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?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(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_images'))
33
33
 
34
- stub_request(:get, "https://api.digitalocean.com/v2/images/12438838?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(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_redmine_image"))
34
+ stub_request(:get, 'https://api.digitalocean.com/v2/images/12438838?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(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_redmine_image'))
37
37
 
38
- @cli.options = @cli.options.merge(:id => 12438838)
39
- @cli.info_image
38
+ cli.options = cli.options.merge(id: 12_438_838)
39
+ cli.info_image
40
40
 
41
41
  expect($stdout.string).to eq <<-eos
42
42
  Image id provided. Finding Image...done\e[0m, 12438838 (Redmine on 14.04)
@@ -49,17 +49,17 @@ Regions: nyc1,ams1,sfo1,nyc2,ams2,sgp1,lon1,nyc3,ams3,fra1
49
49
  eos
50
50
  end
51
51
 
52
- it "shows an image with a name" do
53
- stub_request(:get, "https://api.digitalocean.com/v2/images?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.9.2'}).
55
- to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
52
+ it 'shows an image with a name' do
53
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?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(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_images'))
56
56
 
57
- stub_request(:get, "https://api.digitalocean.com/v2/images/12438838?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(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_redmine_image"))
57
+ stub_request(:get, 'https://api.digitalocean.com/v2/images/12438838?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(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_redmine_image'))
60
60
 
61
- @cli.options = @cli.options.merge(:name => "Redmine on 14.04")
62
- @cli.info_image
61
+ cli.options = cli.options.merge(name: 'Redmine on 14.04')
62
+ cli.info_image
63
63
 
64
64
  expect($stdout.string).to eq <<-eos
65
65
  Image name provided. Finding Image...done\e[0m, 12438838 (Redmine on 14.04)
@@ -72,30 +72,30 @@ Regions: nyc1,ams1,sfo1,nyc2,ams2,sgp1,lon1,nyc3,ams3,fra1
72
72
  eos
73
73
  end
74
74
 
75
- it "errors if no image with matching id is found" do
76
- stub_request(:get, "https://api.digitalocean.com/v2/images?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.9.2'}).
78
- to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
75
+ it 'errors if no image with matching id is found' do
76
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?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(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_images'))
79
79
 
80
- stub_request(:get, "https://api.digitalocean.com/v2/images/123?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.9.2'}).
82
- to_return(:status => 404, :body => fixture('not_found'), :headers => {})
80
+ stub_request(:get, 'https://api.digitalocean.com/v2/images/123?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: 404, body: fixture('not_found'), headers: {})
83
83
 
84
- @cli.options = @cli.options.merge(:id => '123')
85
- expect {@cli.info_image}.to raise_error(SystemExit)
84
+ cli.options = cli.options.merge(id: '123')
85
+ expect { cli.info_image }.to raise_error(SystemExit)
86
86
 
87
87
  expect($stdout.string).to eq <<-eos
88
88
  Image id provided. Finding Image...Failed to find Image: The resource you were accessing could not be found.
89
89
  eos
90
90
  end
91
91
 
92
- it "errors if no image with matching name is found" do
93
- stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
94
- 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'}).
95
- to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
92
+ it 'errors if no image with matching name is found' do
93
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
94
+ 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' }).
95
+ to_return(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_images'))
96
96
 
97
- @cli.options = @cli.options.merge(:name => 'foobarbaz')
98
- expect {@cli.info_image}.to raise_error(SystemExit)
97
+ cli.options = cli.options.merge(name: 'foobarbaz')
98
+ expect { cli.info_image }.to raise_error(SystemExit)
99
99
 
100
100
  expect($stdout.string).to eq <<-eos
101
101
  Image name provided. Finding Image...error
@@ -103,12 +103,12 @@ Unable to find an image named 'foobarbaz'.
103
103
  eos
104
104
  end
105
105
 
106
- it "errors if no image with matching fuzzy name is found" do
107
- stub_request(:get, "https://api.digitalocean.com/v2/images?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.9.2'}).
109
- to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
106
+ it 'errors if no image with matching fuzzy name is found' do
107
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?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(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_images'))
110
110
 
111
- expect {@cli.info_image("foobarbaz")}.to raise_error(SystemExit)
111
+ expect { cli.info_image('foobarbaz') }.to raise_error(SystemExit)
112
112
 
113
113
  expect($stdout.string).to eq <<-eos
114
114
  Image fuzzy name provided. Finding image ID...error
@@ -116,18 +116,18 @@ Unable to find an image named 'foobarbaz'.
116
116
  eos
117
117
  end
118
118
 
119
- it "allows choice of multiple images" do
120
- stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
121
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
122
- to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_images"))
119
+ it 'allows choice of multiple images' do
120
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
121
+ with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
122
+ to_return(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_images'))
123
123
 
124
- stub_request(:get, "https://api.digitalocean.com/v2/images/9801951?per_page=200").
125
- 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'}).
126
- to_return(:status => 200, :body => fixture('ubuntu_image_9801951'), :headers => {})
124
+ stub_request(:get, 'https://api.digitalocean.com/v2/images/9801951?per_page=200').
125
+ 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' }).
126
+ to_return(status: 200, body: fixture('ubuntu_image_9801951'), headers: {})
127
127
 
128
- $stdin.should_receive(:gets).and_return('0')
128
+ $stdin.should_receive(:gets).and_return('0')
129
129
 
130
- @cli.info_image("ubun")
130
+ cli.info_image('ubun')
131
131
 
132
132
  expect($stdout.string).to eq <<-eos
133
133
  Image fuzzy name provided. Finding image ID...Multiple images found.
@@ -149,8 +149,5 @@ Min Disk Size: 20GB
149
149
  Regions: nyc1,ams1,sfo1,nyc2,ams2,sgp1,lon1,nyc3,ams3,fra1
150
150
  eos
151
151
  end
152
-
153
-
154
152
  end
155
-
156
153
  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 "keys" do
7
- it "shows a list" do
6
+ describe 'keys' do
7
+ it 'shows a list' do
8
+ stub_request(:get, 'https://api.digitalocean.com/v2/account/keys?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_keys'), headers: {})
8
11
 
9
- stub_request(:get, "https://api.digitalocean.com/v2/account/keys?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(:status => 200, :body => fixture('show_keys'), :headers => {})
12
-
13
- @cli.keys
12
+ cli.keys
14
13
 
15
14
  expect($stdout.string).to eq <<-eos
16
15
  SSH Keys:
@@ -18,8 +17,7 @@ Name: My SSH Public Key, (id: 512189), fingerprint: 3b:16:bf:e4:8b:00:8b:b8:59:8
18
17
  Name: My Other SSH Public Key, (id: 512110), fingerprint: 3b:16:bf:d4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa
19
18
  eos
20
19
 
21
- expect(a_request(:get, "https://api.digitalocean.com/v2/account/keys?per_page=200")).to have_been_made
20
+ expect(a_request(:get, 'https://api.digitalocean.com/v2/account/keys?per_page=200')).to have_been_made
22
21
  end
23
22
  end
24
23
  end
25
-
@@ -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 "passwordreset" do
7
- it "resets the root password given 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 'passwordreset' do
7
+ it 'resets the root password given 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 => {'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
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
17
- with(:body => "{\"type\":\"password_reset\"}",
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('password_reset_response'), :headers => {})
16
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
17
+ with(body: '{"type":"password_reset"}',
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('password_reset_response'), headers: {})
20
20
 
21
- @cli.password_reset("example.com")
21
+ cli.password_reset('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)
@@ -27,26 +27,26 @@ Your new root password will be emailed to you
27
27
  eos
28
28
  end
29
29
 
30
- it "resets the root password given 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 'resets the root password given 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?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 => {'Content-Type' => 'application/json'},)
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.11.0' }).
37
+ to_return(status: 200, body: fixture('show_droplets'), headers: { 'Content-Type' => 'application/json' })
38
38
 
39
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
40
- 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'}).
41
- to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
39
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
40
+ 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' }).
41
+ to_return(status: 200, body: fixture('show_droplet'), headers: {})
42
42
 
43
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
44
- with(:body => "{\"type\":\"password_reset\"}",
45
- :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'}).
46
- to_return(:status => 200, :body => fixture('password_reset_response'), :headers => {})
43
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
44
+ with(body: '{"type":"password_reset"}',
45
+ 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' }).
46
+ to_return(status: 200, body: fixture('password_reset_response'), headers: {})
47
47
 
48
- @cli.options = @cli.options.merge(:id => 6918990)
49
- @cli.password_reset
48
+ cli.options = cli.options.merge(id: 6_918_990)
49
+ cli.password_reset
50
50
 
51
51
  expect($stdout.string).to eq <<-eos
52
52
  Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
@@ -55,22 +55,22 @@ Your new root password will be emailed to you
55
55
  eos
56
56
  end
57
57
 
58
- it "resets the root password given a name" do
59
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
60
- 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'}).
61
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
58
+ it 'resets the root password given a name' do
59
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
60
+ 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' }).
61
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
62
62
 
63
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
64
- 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'}).
65
- to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
63
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
64
+ 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' }).
65
+ to_return(status: 200, body: fixture('show_droplets'), headers: { 'Content-Type' => 'application/json' })
66
66
 
67
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
68
- with(:body => "{\"type\":\"password_reset\"}",
69
- :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 => 200, :body => fixture('password_reset_response'), :headers => {})
67
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
68
+ with(body: '{"type":"password_reset"}',
69
+ 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' }).
70
+ to_return(status: 200, body: fixture('password_reset_response'), headers: {})
71
71
 
72
- @cli.options = @cli.options.merge(:name => "example.com")
73
- @cli.password_reset
72
+ cli.options = cli.options.merge(name: 'example.com')
73
+ cli.password_reset
74
74
 
75
75
  expect($stdout.string).to eq <<-eos
76
76
  Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
@@ -79,23 +79,23 @@ Your new root password will be emailed to you
79
79
  eos
80
80
  end
81
81
 
82
- it "raises SystemExit when a request fails" do
83
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
84
- 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'}).
85
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
82
+ it 'raises SystemExit when a request fails' do
83
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
84
+ 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' }).
85
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
86
86
 
87
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
88
- 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'}).
89
- to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
87
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
88
+ 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' }).
89
+ to_return(status: 200, body: fixture('show_droplets'), headers: { 'Content-Type' => 'application/json' })
90
90
 
91
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
92
- with(:body => "{\"type\":\"password_reset\"}",
93
- :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'}).
94
- to_return(:headers => {'Content-Type' => 'application/json'}, :status => 500, :body => '{"status":"ERROR","message":"Some error"}')
91
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
92
+ with(body: '{"type":"password_reset"}',
93
+ 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' }).
94
+ to_return(headers: { 'Content-Type' => 'application/json' }, status: 500, body: '{"status":"ERROR","message":"Some error"}')
95
95
 
96
- @cli.options = @cli.options.merge(:name => "example.com")
96
+ cli.options = cli.options.merge(name: 'example.com')
97
97
 
98
- expect{ @cli.password_reset("example.com") }.to raise_error(SystemExit)
98
+ expect { cli.password_reset('example.com') }.to raise_error(SystemExit)
99
99
  end
100
100
  end
101
101
  end
@@ -1,61 +1,60 @@
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 "rebuild" do
7
- it "rebuilds a droplet with a fuzzy name based on an image 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 'rebuild' do
7
+ it 'rebuilds a droplet with a fuzzy name based on an image 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(:get, "https://api.digitalocean.com/v2/images?per_page=200").
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 => 200, :body => fixture('show_images'), :headers => {})
16
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
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_images'), headers: {})
19
19
 
20
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
21
- with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
22
- :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'}).
23
- to_return(:status => 200, :body => "", :headers => {})
20
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
21
+ with(body: '{"type":"rebuild","image":12790328}',
22
+ 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' }).
23
+ to_return(status: 200, body: '', headers: {})
24
24
 
25
- expect($stdin).to receive(:gets).and_return("y")
25
+ expect($stdin).to receive(:gets).and_return('y')
26
26
 
27
- @cli.rebuild("example.com", "ubuntu-14-04-x64")
27
+ cli.rebuild('example.com', 'ubuntu-14-04-x64')
28
28
 
29
29
  expect($stdout.string).to eq <<-eos
30
30
  Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
31
31
  Image fuzzy name provided. Finding image ID...done\e[0m, 12790328 (14.04 x64)
32
32
  Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild for droplet 6918990 (example.com) with image 12790328 (14.04 x64)...Rebuild complete
33
33
  eos
34
-
35
34
  end
36
35
 
37
- it "rebuilds a droplet with an id based on an image with a fuzzy name" do
38
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
39
- 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'}).
40
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
36
+ it 'rebuilds a droplet with an id based on an image with a fuzzy name' do
37
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
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(status: 200, body: fixture('show_droplets'), headers: {})
41
40
 
42
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?per_page=200").
43
- 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'}).
44
- to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
41
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/12790328?per_page=200').
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.11.0' }).
43
+ to_return(status: 200, body: fixture('show_droplet'), headers: {})
45
44
 
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'), :headers => {})
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'), headers: {})
49
48
 
50
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
51
- with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
52
- :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'}).
53
- to_return(:status => 200, :body => "", :headers => {})
49
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
50
+ with(body: '{"type":"rebuild","image":12790328}',
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: '', headers: {})
54
53
 
55
- expect($stdin).to receive(:gets).and_return("y")
54
+ expect($stdin).to receive(:gets).and_return('y')
56
55
 
57
- @cli.options = @cli.options.merge(:id => '12790328')
58
- @cli.rebuild("example.com","ubuntu-14-04-x64")
56
+ cli.options = cli.options.merge(id: '12790328')
57
+ cli.rebuild('example.com', 'ubuntu-14-04-x64')
59
58
 
60
59
  expect($stdout.string).to eq <<-eos
61
60
  Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
@@ -64,71 +63,70 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
64
63
  eos
65
64
  end
66
65
 
67
- it "rebuilds a droplet with a name based on an image with a fuzzy name" do
68
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
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 => 200, :body => fixture('show_droplets'), :headers => {})
66
+ it 'rebuilds a droplet with a name based on an image with a fuzzy name' 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: {})
71
70
 
72
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
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.9.2'}).
74
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
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: {})
75
74
 
76
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?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.9.2'}).
78
- to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
75
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/12790328?per_page=200').
76
+ 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' }).
77
+ to_return(status: 200, body: fixture('show_droplet'), headers: {})
79
78
 
80
- stub_request(:get, "https://api.digitalocean.com/v2/images?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.9.2'}).
82
- to_return(:status => 200, :body => fixture('show_images'), :headers => {})
79
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
80
+ 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' }).
81
+ to_return(status: 200, body: fixture('show_images'), headers: {})
83
82
 
84
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
85
- with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
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.9.2'}).
87
- to_return(:status => 200, :body => "", :headers => {})
83
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
84
+ with(body: '{"type":"rebuild","image":12790328}',
85
+ 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: '', headers: {})
88
87
 
89
- expect($stdin).to receive(:gets).and_return("y")
88
+ expect($stdin).to receive(:gets).and_return('y')
90
89
 
91
- @cli.options = @cli.options.merge(:name => 'example.com')
92
- @cli.rebuild("example.com","ubuntu-14-04-x64")
90
+ cli.options = cli.options.merge(name: 'example.com')
91
+ cli.rebuild('example.com', 'ubuntu-14-04-x64')
93
92
 
94
93
  expect($stdout.string).to eq <<-eos
95
94
  Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
96
95
  Image fuzzy name provided. Finding image ID...done\e[0m, 12790328 (14.04 x64)
97
96
  Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild for droplet 6918990 (example.com) with image 12790328 (14.04 x64)...Rebuild complete
98
97
  eos
99
-
100
98
  end
101
99
 
102
- it "rebuilds a droplet with a fuzzy name based on an image with an id" 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.9.2'}).
105
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
100
+ it 'rebuilds a droplet with a fuzzy name based on an image with an id' do
101
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
102
+ 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' }).
103
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
106
104
 
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.9.2'}).
109
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
105
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
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.11.0' }).
107
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
110
108
 
111
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?per_page=200").
112
- 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'}).
113
- to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
109
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/12790328?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.11.0' }).
111
+ to_return(status: 200, body: fixture('show_droplet'), headers: {})
114
112
 
115
- stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
116
- 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'}).
117
- to_return(:status => 200, :body => fixture('show_images'), :headers => {})
113
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
114
+ 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' }).
115
+ to_return(status: 200, body: fixture('show_images'), headers: {})
118
116
 
119
- stub_request(:get, "https://api.digitalocean.com/v2/images/12790328?per_page=200").
120
- 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'}).
121
- to_return(:status => 200, :body => fixture('show_image'), :headers => {})
117
+ stub_request(:get, 'https://api.digitalocean.com/v2/images/12790328?per_page=200').
118
+ 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' }).
119
+ to_return(status: 200, body: fixture('show_image'), headers: {})
122
120
 
123
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
124
- with(:body => "{\"type\":\"rebuild\",\"image\":6376601}",
125
- :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'}).
126
- to_return(:status => 200, :body => "", :headers => {})
121
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
122
+ with(body: '{"type":"rebuild","image":6376601}',
123
+ 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' }).
124
+ to_return(status: 200, body: '', headers: {})
127
125
 
128
- expect($stdin).to receive(:gets).and_return("y")
126
+ expect($stdin).to receive(:gets).and_return('y')
129
127
 
130
- @cli.options = @cli.options.merge(:image_id => 12790328)
131
- @cli.rebuild("example.com","ubuntu-14-04-x64")
128
+ cli.options = cli.options.merge(image_id: 12_790_328)
129
+ cli.rebuild('example.com', 'ubuntu-14-04-x64')
132
130
 
133
131
  expect($stdout.string).to eq <<-eos
134
132
  Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
@@ -137,36 +135,36 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
137
135
  eos
138
136
  end
139
137
 
140
- it "rebuilds a droplet with an id based on an image with an id" do
141
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
142
- 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'}).
143
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
138
+ it 'rebuilds a droplet with an id based on an image with an id' do
139
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
140
+ 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' }).
141
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
144
142
 
145
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
146
- 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'}).
147
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
143
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
144
+ with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
145
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
148
146
 
149
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?per_page=200").
150
- 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'}).
151
- to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
147
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/12790328?per_page=200').
148
+ with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
149
+ to_return(status: 200, body: fixture('show_droplet'), headers: {})
152
150
 
153
- stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
154
- 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'}).
155
- to_return(:status => 200, :body => fixture('show_images'), :headers => {})
151
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
152
+ with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
153
+ to_return(status: 200, body: fixture('show_images'), headers: {})
156
154
 
157
- stub_request(:get, "https://api.digitalocean.com/v2/images/12790328?per_page=200").
158
- 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'}).
159
- to_return(:status => 200, :body => fixture('show_image'), :headers => {})
155
+ stub_request(:get, 'https://api.digitalocean.com/v2/images/12790328?per_page=200').
156
+ 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' }).
157
+ to_return(status: 200, body: fixture('show_image'), headers: {})
160
158
 
161
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
162
- with(:body => "{\"type\":\"rebuild\",\"image\":6376601}",
163
- :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'}).
164
- to_return(:status => 200, :body => "", :headers => {})
159
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
160
+ with(body: '{"type":"rebuild","image":6376601}',
161
+ 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' }).
162
+ to_return(status: 200, body: '', headers: {})
165
163
 
166
- expect($stdin).to receive(:gets).and_return("y")
164
+ expect($stdin).to receive(:gets).and_return('y')
167
165
 
168
- @cli.options = @cli.options.merge(:id => '12790328', :image_id => 12790328)
169
- @cli.rebuild("example.com","ubuntu-14-04-x64")
166
+ cli.options = cli.options.merge(id: '12790328', image_id: 12_790_328)
167
+ cli.rebuild('example.com', 'ubuntu-14-04-x64')
170
168
 
171
169
  expect($stdout.string).to eq <<-eos
172
170
  Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
@@ -175,36 +173,36 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
175
173
  eos
176
174
  end
177
175
 
178
- it "rebuilds a droplet with a name based on an image with an id" do
179
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
180
- 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'}).
181
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
176
+ it 'rebuilds a droplet with a name based on an image with an id' do
177
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
178
+ 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' }).
179
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
182
180
 
183
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
184
- 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'}).
185
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
181
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
182
+ with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
183
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
186
184
 
187
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?per_page=200").
188
- 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'}).
189
- to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
185
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/12790328?per_page=200').
186
+ with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer foo', 'Content-Type' => 'application/json', 'User-Agent' => 'Faraday v0.11.0' }).
187
+ to_return(status: 200, body: fixture('show_droplet'), headers: {})
190
188
 
191
- stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
192
- 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'}).
193
- to_return(:status => 200, :body => fixture('show_images'), :headers => {})
189
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
190
+ 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' }).
191
+ to_return(status: 200, body: fixture('show_images'), headers: {})
194
192
 
195
- stub_request(:get, "https://api.digitalocean.com/v2/images/12790328?per_page=200").
196
- 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'}).
197
- to_return(:status => 200, :body => fixture('show_image'), :headers => {})
193
+ stub_request(:get, 'https://api.digitalocean.com/v2/images/12790328?per_page=200').
194
+ 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' }).
195
+ to_return(status: 200, body: fixture('show_image'), headers: {})
198
196
 
199
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
200
- with(:body => "{\"type\":\"rebuild\",\"image\":6376601}",
201
- :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'}).
202
- to_return(:status => 200, :body => "", :headers => {})
197
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
198
+ with(body: '{"type":"rebuild","image":6376601}',
199
+ 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' }).
200
+ to_return(status: 200, body: '', headers: {})
203
201
 
204
- expect($stdin).to receive(:gets).and_return("y")
202
+ expect($stdin).to receive(:gets).and_return('y')
205
203
 
206
- @cli.options = @cli.options.merge(:name => 'example.com', :image_id => 12790328)
207
- @cli.rebuild("example.com","ubuntu-14-04-x64")
204
+ cli.options = cli.options.merge(name: 'example.com', image_id: 12_790_328)
205
+ cli.rebuild('example.com', 'ubuntu-14-04-x64')
208
206
 
209
207
  expect($stdout.string).to eq <<-eos
210
208
  Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
@@ -213,29 +211,29 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
213
211
  eos
214
212
  end
215
213
 
216
- it "rebuilds a droplet with a fuzzy name based on an image with a name" do
217
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
218
- 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'}).
219
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
214
+ it 'rebuilds a droplet with a fuzzy name based on an image with a name' do
215
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
216
+ 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' }).
217
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
220
218
 
221
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
222
- 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'}).
223
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
219
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
220
+ 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' }).
221
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
224
222
 
225
- stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
226
- 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'}).
227
- to_return(:status => 200, :body => fixture('show_images'), :headers => {})
223
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
224
+ 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' }).
225
+ to_return(status: 200, body: fixture('show_images'), headers: {})
228
226
 
229
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
230
- with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
231
- :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'}).
232
- to_return(:status => 200, :body => "", :headers => {})
227
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
228
+ with(body: '{"type":"rebuild","image":12790328}',
229
+ 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' }).
230
+ to_return(status: 200, body: '', headers: {})
233
231
 
234
- expect($stdin).to receive(:gets).and_return("y")
232
+ expect($stdin).to receive(:gets).and_return('y')
235
233
 
236
- @cli.options = @cli.options.merge(:image_name => "14.04 x64")
234
+ cli.options = cli.options.merge(image_name: '14.04 x64')
237
235
 
238
- @cli.rebuild("example.com","ubuntu-14-04-x64")
236
+ cli.rebuild('example.com', 'ubuntu-14-04-x64')
239
237
 
240
238
  expect($stdout.string).to eq <<-eos
241
239
  Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
@@ -244,32 +242,32 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
244
242
  eos
245
243
  end
246
244
 
247
- it "rebuilds a droplet with an id based on an image with a name" do
248
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
249
- 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'}).
250
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
245
+ it 'rebuilds a droplet with an id based on an image with a name' do
246
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
247
+ 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' }).
248
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
251
249
 
252
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
253
- 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'}).
254
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
250
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
251
+ 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' }).
252
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
255
253
 
256
- stub_request(:get, "https://api.digitalocean.com/v2/droplets/12790328?per_page=200").
257
- 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'}).
258
- to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
254
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets/12790328?per_page=200').
255
+ 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' }).
256
+ to_return(status: 200, body: fixture('show_droplet'), headers: {})
259
257
 
260
- stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
261
- 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'}).
262
- to_return(:status => 200, :body => fixture('show_images'), :headers => {})
258
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
259
+ 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' }).
260
+ to_return(status: 200, body: fixture('show_images'), headers: {})
263
261
 
264
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
265
- with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
266
- :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'}).
267
- to_return(:status => 200, :body => "", :headers => {})
262
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
263
+ with(body: '{"type":"rebuild","image":12790328}',
264
+ 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' }).
265
+ to_return(status: 200, body: '', headers: {})
268
266
 
269
- expect($stdin).to receive(:gets).and_return("y")
267
+ expect($stdin).to receive(:gets).and_return('y')
270
268
 
271
- @cli.options = @cli.options.merge(:id => '12790328', :image_name => "14.04 x64")
272
- @cli.rebuild("example.com", "14.04 x64")
269
+ cli.options = cli.options.merge(id: '12790328', image_name: '14.04 x64')
270
+ cli.rebuild('example.com', '14.04 x64')
273
271
 
274
272
  expect($stdout.string).to eq <<-eos
275
273
  Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
@@ -278,28 +276,28 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
278
276
  eos
279
277
  end
280
278
 
281
- it "rebuilds a droplet with a name based on an image with a name" do
282
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
283
- 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'}).
284
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
279
+ it 'rebuilds a droplet with a name based on an image with a name' do
280
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
281
+ 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' }).
282
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
285
283
 
286
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
287
- 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'}).
288
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
284
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
285
+ 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' }).
286
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
289
287
 
290
- stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
291
- 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'}).
292
- to_return(:status => 200, :body => fixture('show_images'), :headers => {})
288
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
289
+ 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' }).
290
+ to_return(status: 200, body: fixture('show_images'), headers: {})
293
291
 
294
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
295
- with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
296
- :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'}).
297
- to_return(:status => 200, :body => "", :headers => {})
292
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
293
+ with(body: '{"type":"rebuild","image":12790328}',
294
+ 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' }).
295
+ to_return(status: 200, body: '', headers: {})
298
296
 
299
- expect($stdin).to receive(:gets).and_return("y")
297
+ expect($stdin).to receive(:gets).and_return('y')
300
298
 
301
- @cli.options = @cli.options.merge(:name => 'example.com', :image_name => "14.04 x64")
302
- @cli.rebuild("example.com", "14.04 x64")
299
+ cli.options = cli.options.merge(name: 'example.com', image_name: '14.04 x64')
300
+ cli.rebuild('example.com', '14.04 x64')
303
301
 
304
302
  expect($stdout.string).to eq <<-eos
305
303
  Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
@@ -308,27 +306,26 @@ Warning! Potentially destructive action. Please confirm [y/n]: Queuing rebuild f
308
306
  eos
309
307
  end
310
308
 
311
- it "rebuilds a droplet with confirm flag set" do
312
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
313
- 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'}).
314
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
309
+ it 'rebuilds a droplet with confirm flag set' do
310
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
311
+ 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' }).
312
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
315
313
 
316
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
317
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
318
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
314
+ stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
315
+ 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' }).
316
+ to_return(status: 200, body: fixture('show_droplets'), headers: {})
319
317
 
320
- stub_request(:get, "https://api.digitalocean.com/v2/images?per_page=200").
321
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
322
- to_return(:status => 200, :body => fixture('show_images'), :headers => {})
318
+ stub_request(:get, 'https://api.digitalocean.com/v2/images?per_page=200').
319
+ 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' }).
320
+ to_return(status: 200, body: fixture('show_images'), headers: {})
323
321
 
324
- stub_request(:post, "https://api.digitalocean.com/v2/droplets/6918990/actions").
325
- with(:body => "{\"type\":\"rebuild\",\"image\":12790328}",
326
- :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'}).
327
- to_return(:status => 200, :body => "", :headers => {})
322
+ stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
323
+ with(body: '{"type":"rebuild","image":12790328}',
324
+ 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' }).
325
+ to_return(status: 200, body: '', headers: {})
328
326
 
329
-
330
- @cli.options = @cli.options.merge(:confirm => "no")
331
- @cli.rebuild("example.com", "14.04 x64")
327
+ cli.options = cli.options.merge(confirm: 'no')
328
+ cli.rebuild('example.com', '14.04 x64')
332
329
 
333
330
  expect($stdout.string).to eq <<-eos
334
331
  Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
@@ -337,5 +334,4 @@ Queuing rebuild for droplet 6918990 (example.com) with image 12790328 (14.04 x64
337
334
  eos
338
335
  end
339
336
  end
340
-
341
337
  end