tugboat 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -3
  3. data/features/{vagrant-adam → tugboat}/config_current_directory.feature +0 -0
  4. data/lib/tugboat/cli.rb +6 -1
  5. data/lib/tugboat/middleware/base.rb +59 -0
  6. data/lib/tugboat/middleware/check_credentials.rb +1 -10
  7. data/lib/tugboat/middleware/find_droplet.rb +23 -18
  8. data/lib/tugboat/middleware/list_droplets.rb +23 -19
  9. data/lib/tugboat/middleware/rebuild_droplet.rb +1 -1
  10. data/lib/tugboat/middleware/snapshot_droplet.rb +1 -1
  11. data/lib/tugboat/middleware/ssh_droplet.rb +15 -2
  12. data/lib/tugboat/middleware/wait_for_state.rb +1 -20
  13. data/lib/tugboat/version.rb +1 -1
  14. data/spec/cli/authorize_cli_spec.rb +2 -2
  15. data/spec/cli/create_cli_spec.rb +10 -10
  16. data/spec/cli/debug_cli_spec.rb +2 -2
  17. data/spec/cli/destroy_cli_spec.rb +22 -6
  18. data/spec/cli/droplets_cli_spec.rb +72 -8
  19. data/spec/cli/env_variable_spec.rb +4 -4
  20. data/spec/cli/halt_cli_spec.rb +24 -4
  21. data/spec/cli/info_cli_spec.rb +55 -10
  22. data/spec/cli/password_reset_cli_spec.rb +20 -4
  23. data/spec/cli/rebuild_cli_spec.rb +59 -19
  24. data/spec/cli/resize_cli_spec.rb +19 -3
  25. data/spec/cli/restart_cli_spec.rb +19 -3
  26. data/spec/cli/snapshot_cli_spec.rb +19 -3
  27. data/spec/cli/ssh_cli_spec.rb +37 -2
  28. data/spec/cli/start_cli_spec.rb +19 -3
  29. data/spec/cli/verify_cli_spec.rb +9 -9
  30. data/spec/cli/wait_cli_spec.rb +19 -3
  31. data/spec/fixtures/401.json +4 -0
  32. data/spec/fixtures/show_droplets.json +0 -4
  33. data/spec/fixtures/show_droplets_paginated_first.json +256 -0
  34. data/spec/fixtures/show_droplets_paginated_last.json +253 -0
  35. data/spec/fixtures/show_droplets_private_ip.json +258 -0
  36. data/spec/middleware/check_credentials_spec.rb +3 -3
  37. data/spec/middleware/ssh_droplet_spec.rb +21 -3
  38. data/tugboat.gemspec +1 -0
  39. metadata +26 -4
@@ -5,7 +5,11 @@ describe Tugboat::CLI do
5
5
 
6
6
  describe "destroy" do
7
7
  it "destroys a droplet with a fuzzy name" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
11
+
12
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
9
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'}).
10
14
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
15
 
@@ -43,7 +47,11 @@ Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)\nWarning
43
47
 
44
48
 
45
49
  it "destroys a droplet with a name" do
46
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
50
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
51
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
52
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
53
+
54
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
47
55
  with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
48
56
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
49
57
 
@@ -62,7 +70,11 @@ Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)\nWa
62
70
  end
63
71
 
64
72
  it "destroys a droplet with confirm flag set" do
65
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
73
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
74
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
75
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
76
+
77
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
66
78
  with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
67
79
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
68
80
 
@@ -80,9 +92,13 @@ Queuing destroy for 6918990 (example.com)...Deletion Successful!
80
92
  end
81
93
 
82
94
  it "does not destroy a droplet if no is chosen" do
83
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
95
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
96
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
97
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
98
+
99
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
100
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
101
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
86
102
 
87
103
  $stdin.should_receive(:gets).and_return("n")
88
104
 
@@ -5,7 +5,11 @@ describe Tugboat::CLI do
5
5
 
6
6
  describe "droplets" do
7
7
  it "shows a list when droplets exist" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
11
+
12
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
9
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'}).
10
14
  to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
11
15
 
@@ -17,11 +21,35 @@ example2.com (ip: 104.236.32.172, status: \e[32mactive\e[0m, region: nyc3, id: 3
17
21
  example3.com (ip: 104.236.32.173, status: \e[31moff\e[0m, region: nyc3, id: 3164444)
18
22
  eos
19
23
 
20
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?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
+ end
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 => {})
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'},)
35
+
36
+ @cli.droplets
37
+
38
+ expect($stdout.string).to eq <<-eos
39
+ exampleprivate.com (ip: 104.236.32.182, private_ip: 10.131.99.89, status: \e[32mactive\e[0m, region: nyc3, id: 6918990)
40
+ example2.com (ip: 104.236.32.172, status: \e[32mactive\e[0m, region: nyc3, id: 3164956)
41
+ example3.com (ip: 104.236.32.173, status: \e[31moff\e[0m, region: nyc3, id: 3164444)
42
+ eos
43
+
44
+ expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200")).to have_been_made
21
45
  end
22
46
 
23
47
  it "returns an error message when no droplets exist" do
24
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
51
+
52
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
25
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'}).
26
54
  to_return(:status => 200, :body => fixture("show_droplets_empty"), :headers => {'Content-Type' => 'application/json'},)
27
55
 
@@ -32,11 +60,15 @@ You don't appear to have any droplets.
32
60
  Try creating one with \e[32m`tugboat create`\e[0m
33
61
  eos
34
62
 
35
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?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
36
64
  end
37
65
 
38
66
  it "shows no output when --quiet is set" do
39
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
70
+
71
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
40
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'}).
41
73
  to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
42
74
 
@@ -46,11 +78,15 @@ Try creating one with \e[32m`tugboat create`\e[0m
46
78
  # Should be /dev/null not stringIO
47
79
  expect($stdout).to be_a File
48
80
 
49
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?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
50
82
  end
51
83
 
52
84
  it "includes urls when --include-urls is set" do
53
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
88
+
89
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
54
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'}).
55
91
  to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
56
92
 
@@ -63,7 +99,35 @@ example2.com (ip: 104.236.32.172, status: \e[32mactive\e[0m, region: nyc3, id: 3
63
99
  example3.com (ip: 104.236.32.173, status: \e[31moff\e[0m, region: nyc3, id: 3164444, url: 'https://cloud.digitalocean.com/droplets/3164444')
64
100
  eos
65
101
 
66
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?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
+ end
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 => {})
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'},)
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'},)
117
+
118
+ @cli.options = @cli.options.merge("include_urls" => true)
119
+ @cli.droplets
120
+
121
+ expect($stdout.string).to eq <<-eos
122
+ page1example.com (ip: 104.236.32.182, status: \e[32mactive\e[0m, region: nyc3, id: 6918990, url: 'https://cloud.digitalocean.com/droplets/6918990')
123
+ page1example2.com (ip: 104.236.32.172, status: \e[32mactive\e[0m, region: nyc3, id: 3164956, url: 'https://cloud.digitalocean.com/droplets/3164956')
124
+ page1example3.com (ip: 104.236.32.173, status: \e[31moff\e[0m, region: nyc3, id: 3164444, url: 'https://cloud.digitalocean.com/droplets/3164444')
125
+ page2example.com (ip: 104.236.32.182, status: \e[32mactive\e[0m, region: nyc3, id: 6918990, url: 'https://cloud.digitalocean.com/droplets/6918990')
126
+ page2example2.com (ip: 104.236.32.172, status: \e[32mactive\e[0m, region: nyc3, id: 3164956, url: 'https://cloud.digitalocean.com/droplets/3164956')
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
+ eos
129
+
130
+ expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200")).to have_been_made
67
131
  end
68
132
  end
69
133
 
@@ -5,7 +5,7 @@ describe Tugboat::CLI do
5
5
 
6
6
  describe "DO_API_TOKEN=foobar" do
7
7
  it "verifies with the ENV variable DO_API_TOKEN" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
8
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
9
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
10
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
11
 
@@ -15,11 +15,11 @@ describe Tugboat::CLI do
15
15
 
16
16
  @cli.verify
17
17
  expect($stdout.string).to eq "Authentication with DigitalOcean was successful.\n"
18
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200")).to have_been_made
18
+ expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1")).to have_been_made
19
19
  end
20
20
 
21
21
  it "does not use ENV variable DO_API_TOKEN if empty" do
22
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
22
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
23
23
  with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
24
24
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
25
25
 
@@ -29,7 +29,7 @@ describe Tugboat::CLI do
29
29
 
30
30
  @cli.verify
31
31
  expect($stdout.string).to eq "Authentication with DigitalOcean was successful.\n"
32
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200")).to have_been_made
32
+ expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1")).to have_been_made
33
33
  end
34
34
  end
35
35
  end
@@ -5,7 +5,11 @@ describe Tugboat::CLI do
5
5
 
6
6
  describe "halt" do
7
7
  it "halts a droplet with a fuzzy name" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
11
+
12
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
9
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'}).
10
14
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
15
 
@@ -23,7 +27,11 @@ Queuing shutdown for 6918990 (example.com)...Halt successful!
23
27
  end
24
28
 
25
29
  it "halts a droplet hard when the hard option is used" do
26
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
33
+
34
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
27
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'}).
28
36
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
29
37
 
@@ -42,6 +50,10 @@ Queuing hard shutdown for 6918990 (example.com)...Halt successful!
42
50
  end
43
51
 
44
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 => {})
56
+
45
57
  stub_request(:get, "https://api.digitalocean.com/v2/droplets/?per_page=200").
46
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'}).
47
59
  to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
@@ -66,7 +78,11 @@ Queuing shutdown for 6918990 (example.com)...Halt successful!
66
78
 
67
79
 
68
80
  it "halts a droplet with a name" do
69
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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
+
85
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
70
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'}).
71
87
  to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
72
88
 
@@ -86,7 +102,11 @@ Queuing shutdown for 6918990 (example.com)...Halt successful!
86
102
 
87
103
 
88
104
  it "does not halt a droplet that is off" do
89
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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").
90
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'}).
91
111
  to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
92
112
 
@@ -5,7 +5,11 @@ describe Tugboat::CLI do
5
5
 
6
6
  describe "info" do
7
7
  it "shows a droplet with a fuzzy name" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
11
+
12
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
9
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'}).
10
14
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
11
15
 
@@ -32,6 +36,10 @@ Backups Active: false
32
36
  end
33
37
 
34
38
  it "shows a droplet made from a user image" do
39
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
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_droplets'), :headers => {})
42
+
35
43
  stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
36
44
  with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
37
45
  to_return(:status => 200, :body => fixture('show_droplet_user_image'), :headers => {})
@@ -55,6 +63,10 @@ Backups Active: false
55
63
  end
56
64
 
57
65
  it "shows a droplet with an id" do
66
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
67
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
68
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
69
+
58
70
  stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
59
71
  with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
60
72
  to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
@@ -78,7 +90,11 @@ Backups Active: false
78
90
  end
79
91
 
80
92
  it "shows a droplet with a name" do
81
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
93
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
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(:status => 200, :body => fixture('show_droplets'), :headers => {})
96
+
97
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
82
98
  with(:headers => {'Accept'=>'*/*', 'Accept-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
99
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
84
100
 
@@ -105,7 +121,11 @@ Backups Active: false
105
121
  end
106
122
 
107
123
  it "allows choice of multiple droplets" do
108
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
124
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
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('show_droplets'), :headers => {})
127
+
128
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
109
129
  with(:headers => {'Accept'=>'*/*', 'Accept-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'}).
110
130
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
111
131
 
@@ -140,6 +160,10 @@ Backups Active: false
140
160
  end
141
161
 
142
162
  it "shows a droplet with an id under porcelain mode" do
163
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
164
+ with(:headers => {'Accept'=>'*/*', 'Accept-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'}).
165
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
166
+
143
167
  stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
144
168
  with(:headers => {'Accept'=>'*/*', 'Accept-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'}).
145
169
  to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
@@ -161,7 +185,11 @@ backups_active false
161
185
  end
162
186
 
163
187
  it "shows a droplet with a name under porcelain mode" do
164
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
188
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
189
+ with(:headers => {'Accept'=>'*/*', 'Accept-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'}).
190
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
191
+
192
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
165
193
  with(:headers => {'Accept'=>'*/*', 'Accept-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'}).
166
194
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
167
195
 
@@ -186,6 +214,10 @@ backups_active false
186
214
  end
187
215
 
188
216
  it "shows a droplet attribute with an id" 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 => {})
220
+
189
221
  stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
190
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'}).
191
223
  to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
@@ -200,7 +232,11 @@ Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
200
232
  end
201
233
 
202
234
  it "shows a droplet attribute with a name" do
203
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
235
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
236
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
237
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
238
+
239
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
204
240
  with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
205
241
  to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
206
242
 
@@ -218,6 +254,10 @@ Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
218
254
  end
219
255
 
220
256
  it "gives error if invalid attribute given" do
257
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
258
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
259
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
260
+
221
261
  stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
222
262
  with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
223
263
  to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
@@ -255,12 +295,17 @@ Provide one of the following:
255
295
  end
256
296
 
257
297
  it "shows a droplet attribute with a name under porcelain mode" do
258
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?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.9.2'}).
260
- to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
298
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
299
+ with(:headers => {'Accept'=>'*/*', 'Accept-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'}).
300
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
301
+
302
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
303
+ with(:headers => {'Accept'=>'*/*', 'Accept-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'}).
304
+ to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
305
+
261
306
  stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
262
- with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
263
- to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
307
+ with(:headers => {'Accept'=>'*/*', 'Accept-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'}).
308
+ to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
264
309
 
265
310
  @cli.options = @cli.options.merge(:name => 'example.com', :porcelain => true, :attribute => "ip4")
266
311
  @cli.info
@@ -5,7 +5,11 @@ describe Tugboat::CLI do
5
5
 
6
6
  describe "passwordreset" do
7
7
  it "resets the root password given a fuzzy name" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
11
+
12
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
9
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'}).
10
14
  to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
11
15
 
@@ -24,7 +28,11 @@ Your new root password will be emailed to you
24
28
  end
25
29
 
26
30
  it "resets the root password given an id" do
27
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
34
+
35
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
28
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'}).
29
37
  to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
30
38
 
@@ -48,7 +56,11 @@ Your new root password will be emailed to you
48
56
  end
49
57
 
50
58
  it "resets the root password given a name" do
51
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
62
+
63
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
52
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'}).
53
65
  to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
54
66
 
@@ -68,7 +80,11 @@ Your new root password will be emailed to you
68
80
  end
69
81
 
70
82
  it "raises SystemExit when a request fails" do
71
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
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 => {})
86
+
87
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
72
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'}).
73
89
  to_return(:status => 200, :body => fixture("show_droplets"), :headers => {'Content-Type' => 'application/json'},)
74
90