digitalocean 0.0.3 → 1.0.0.rc.2

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.
@@ -1,52 +1,141 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Digitalocean::Droplet do
4
- let(:ok) { "OK" }
5
4
  let(:subject) { Digitalocean::Droplet }
6
5
 
7
- context "correct api key" do
6
+ describe "._all" do
8
7
  before do
9
- set_client_id_and_api_key!
8
+ @url = subject._all
10
9
  end
11
10
 
12
- describe ".all" do
13
- before do
14
- @response = subject.all
15
- end
11
+ it do
12
+ @url.should eq "https://api.digitalocean.com/droplets/?client_id=client_id_required&api_key=api_key_required"
13
+ end
14
+ end
15
+
16
+ describe "._find" do
17
+ let(:droplet_id) { "1234" }
18
+
19
+ before do
20
+ @url = subject._find(droplet_id)
21
+ end
22
+
23
+ it do
24
+ @url.should eq "https://api.digitalocean.com/droplets/#{droplet_id}?client_id=client_id_required&api_key=api_key_required"
25
+ end
26
+ end
27
+
28
+ describe "._rename" do
29
+ let(:droplet_id) { "1234" }
30
+ let(:name) { "new_name" }
31
+
32
+ before do
33
+ @url = subject._rename(droplet_id, {name: name})
34
+ end
35
+
36
+ it do
37
+ @url.should eq "https://api.digitalocean.com/droplets/#{droplet_id}/rename/?client_id=client_id_required&api_key=api_key_required&name=#{name}"
38
+ end
39
+ end
40
+
41
+ describe "._reboot" do
42
+ let(:droplet_id) { "1234" }
16
43
 
17
- context "default" do
18
- it do
19
- @response.status.should eq ok
20
- end
21
- end
44
+ before do
45
+ @url = subject._reboot(droplet_id)
46
+ end
47
+
48
+ it do
49
+ @url.should eq "https://api.digitalocean.com/droplets/#{droplet_id}/reboot/?client_id=client_id_required&api_key=api_key_required"
50
+ end
51
+ end
52
+
53
+ describe "._power_cycle" do
54
+ let(:droplet_id) { "1234" }
55
+
56
+ before do
57
+ @url = subject._power_cycle(droplet_id)
58
+ end
59
+
60
+ it do
61
+ @url.should eq "https://api.digitalocean.com/droplets/#{droplet_id}/power_cycle/?client_id=client_id_required&api_key=api_key_required"
62
+ end
63
+ end
22
64
 
23
- describe ".retrieve" do
24
- before do
25
- droplet_id = @response.droplets.first.id
26
- @response2 = subject.retrieve(droplet_id)
27
- end
65
+ describe "._shut_down" do
66
+ let(:droplet_id) { "1234" }
28
67
 
29
- context "default" do
30
- it do
31
- @response2.status.should eq ok
32
- end
33
- end
34
- end
68
+ before do
69
+ @url = subject._shut_down(droplet_id)
70
+ end
35
71
 
36
- describe ".snapshot" do
37
- let(:snapshot_name) { ["digitalocean_spec_", SecureRandom.hex(15)].join }
72
+ it do
73
+ @url.should eq "https://api.digitalocean.com/droplets/#{droplet_id}/shut_down/?client_id=client_id_required&api_key=api_key_required"
74
+ end
75
+ end
38
76
 
39
- before do
40
- droplet_id = @response.droplets.first.id
41
- @response2 = subject.snapshot(droplet_id, snapshot_name)
42
- end
77
+ describe "._power_off" do
78
+ let(:droplet_id) { "1234" }
79
+
80
+ before do
81
+ @url = subject._power_off(droplet_id)
82
+ end
83
+
84
+ it do
85
+ @url.should eq "https://api.digitalocean.com/droplets/#{droplet_id}/power_off/?client_id=client_id_required&api_key=api_key_required"
86
+ end
87
+ end
88
+
89
+ describe "._power_on" do
90
+ let(:droplet_id) { "1234" }
91
+
92
+ before do
93
+ @url = subject._power_on(droplet_id)
94
+ end
95
+
96
+ it do
97
+ @url.should eq "https://api.digitalocean.com/droplets/#{droplet_id}/power_on/?client_id=client_id_required&api_key=api_key_required"
98
+ end
99
+ end
100
+
101
+ describe "._snapshot" do
102
+ let(:droplet_id) { "1234" }
103
+ let(:snapshot_name) { "test_name" }
104
+
105
+ before do
106
+ @url = subject._snapshot(droplet_id, {name: snapshot_name})
107
+ end
108
+
109
+ it do
110
+ @url.should eq "https://api.digitalocean.com/droplets/#{droplet_id}/snapshot/?name=#{snapshot_name}&client_id=client_id_required&api_key=api_key_required"
111
+ end
112
+ end
113
+
114
+ describe "._create" do
115
+ let(:name) { "test_name" }
116
+ let(:size_id) { "1234" }
117
+ let(:image_id) { "11" }
118
+ let(:region_id) { "44" }
119
+ let(:ssh_key_ids) { "12,92" }
120
+
121
+ before do
122
+ @url = subject._create({name: name, size_id: size_id, image_id: image_id, region_id: region_id, ssh_key_ids: ssh_key_ids})
123
+ end
124
+
125
+ it do
126
+ @url.should eq "https://api.digitalocean.com/droplets/new?client_id=client_id_required&api_key=api_key_required&name=#{name}&size_id=#{size_id}&image_id=#{image_id}&region_id=#{region_id}&ssh_key_ids=#{ssh_key_ids}"
127
+ end
128
+ end
129
+
130
+ describe "._destroy" do
131
+ let(:droplet_id) { "1234" }
132
+
133
+ before do
134
+ @url = subject._destroy(droplet_id)
135
+ end
43
136
 
44
- context "default" do
45
- it do
46
- @response2.status.should eq ok
47
- end
48
- end
49
- end
137
+ it do
138
+ @url.should eq "https://api.digitalocean.com/droplets/#{droplet_id}/destroy/?client_id=client_id_required&api_key=api_key_required"
50
139
  end
51
140
  end
52
- end
141
+ end
@@ -1,39 +1,65 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Digitalocean::Image do
4
- let(:ok) { "OK" }
5
4
  let(:subject) { Digitalocean::Image }
6
5
 
7
- context "correct api key" do
6
+ describe "._all" do
8
7
  before do
9
- set_client_id_and_api_key!
8
+ @url = subject._all
10
9
  end
11
10
 
12
- describe ".all" do
13
- before do
14
- @response = subject.all
15
- end
11
+ it do
12
+ @url.should eq "https://api.digitalocean.com/images/?client_id=client_id_required&api_key=api_key_required"
13
+ end
14
+ end
15
+
16
+ describe "._all with optional parameters" do
17
+ let(:args) { { filter: "my_images" } }
18
+
19
+ before do
20
+ @url = subject._all(args)
21
+ end
22
+
23
+ it do
24
+ @url.should eq "https://api.digitalocean.com/images/?client_id=client_id_required&api_key=api_key_required&filter=my_images"
25
+ end
26
+ end
27
+
28
+ describe "._find" do
29
+ let(:id) { "1234" }
30
+
31
+ before do
32
+ @url = subject._find(id)
33
+ end
16
34
 
17
- context "default" do
18
- it do
19
- @response.status.should eq ok
20
- end
21
- end
35
+ it do
36
+ @url.should eq "https://api.digitalocean.com/images/#{id}/?client_id=client_id_required&api_key=api_key_required"
22
37
  end
38
+ end
23
39
 
24
- describe ".find" do
25
- before do
26
- image_id = @response.images.first.id
27
- @response2 = subject.retrieve(image_id)
28
- end
40
+ describe "._destroy" do
41
+ let(:id) { "1234" }
29
42
 
30
- context "default" do
31
- it do
32
- @response.status.should eq ok
33
- end
34
- end
43
+ before do
44
+ @url = subject._destroy(id)
35
45
  end
36
46
 
47
+ it do
48
+ @url.should eq "https://api.digitalocean.com/images/#{id}/destroy/?client_id=client_id_required&api_key=api_key_required"
49
+ end
50
+ end
37
51
 
52
+ describe "._transfer" do
53
+ let(:id) { "1234" }
54
+ let(:region_id) { "44" }
55
+ let(:args) { {region_id: region_id } }
56
+
57
+ before do
58
+ @url = subject._transfer(id, args)
59
+ end
60
+
61
+ it do
62
+ @url.should eq "https://api.digitalocean.com/images/#{id}/transfer/?client_id=client_id_required&api_key=api_key_required&region_id=44"
63
+ end
38
64
  end
39
- end
65
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe "integrations" do
4
+ before do
5
+ Digitalocean.send(:setup_request!)
6
+ end
7
+
8
+ it "makes a real call" do
9
+ regions = Digitalocean::Region.all
10
+ regions.status.should eq "ERROR"
11
+ end
12
+ end
@@ -1,85 +1,74 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Digitalocean::Record do
4
- let(:ok) { "OK" }
5
4
  let(:subject) { Digitalocean::Record }
6
5
 
7
- context "correct api key" do
6
+ describe "._all" do
7
+ let(:domain_id) { "100" }
8
+
9
+ before do
10
+ @url = subject._all(domain_id)
11
+ end
12
+
13
+ it do
14
+ @url.should eq "https://api.digitalocean.com/domains/#{domain_id}/records?client_id=client_id_required&api_key=api_key_required"
15
+ end
16
+ end
17
+
18
+ describe "._find" do
19
+ let(:domain_id) { "100" }
20
+ let(:record_id) { "50" }
21
+
22
+ before do
23
+ @url = subject._find(domain_id, record_id)
24
+ end
25
+
26
+ it do
27
+ @url.should eq "https://api.digitalocean.com/domains/#{domain_id}/records/#{record_id}?client_id=client_id_required&api_key=api_key_required"
28
+ end
29
+ end
30
+
31
+ describe "._create" do
32
+ let(:domain_id) { "100" }
33
+ let(:record_type) { "A" }
34
+ let(:data) { "@" }
35
+ let(:attrs) { {record_type: record_type, data: data } }
36
+
37
+ before do
38
+ @url = subject._create(domain_id, attrs)
39
+ end
40
+
41
+ it do
42
+ @url.should eq "https://api.digitalocean.com/domains/#{domain_id}/records/new?client_id=client_id_required&api_key=api_key_required&record_type=#{record_type}&data=#{data}"
43
+ end
44
+ end
45
+
46
+ describe "._edit" do
47
+ let(:domain_id) { "100" }
48
+ let(:record_id) { "50" }
49
+ let(:record_type) { "A" }
50
+ let(:data) { "@" }
51
+ let(:attrs) { {record_type: record_type, data: data } }
52
+
8
53
  before do
9
- set_client_id_and_api_key!
54
+ @url = subject._edit(domain_id, record_id, attrs)
55
+ end
56
+
57
+ it do
58
+ @url.should eq "https://api.digitalocean.com/domains/#{domain_id}/records/#{record_id}/edit?client_id=client_id_required&api_key=api_key_required&record_type=#{record_type}&data=#{data}"
10
59
  end
60
+ end
11
61
 
12
- describe ".all" do
13
- before do
14
- domain_id = @response.domains.first.id
15
- @response = subject.all(domain_id)
16
- end
17
-
18
- context "default" do
19
- it do
20
- @response.status.should eq ok
21
- end
22
- end
23
-
24
- describe ".find" do
25
- before do
26
- domain_id = @response.domains.first.id
27
- record_id = subject.all(domain_id).first.id
28
- @response2 = subject.find(domain_id, record_id)
29
- end
30
-
31
- context "default" do
32
- it do
33
- @response2.status.should eq ok
34
- end
35
- end
36
- end
37
-
38
- describe ".create" do
39
- let(:domain_name) { ["digitalocean_spec_", SecureRandom.hex(15), ".com"].join }
40
-
41
- before do
42
- domain = @response.domains.first
43
- @response_create = subject.create(domain.id, 'CNAME', 'www', '@')
44
- end
45
-
46
- context "default" do
47
- it do
48
- @response_create.status.should eq ok
49
- end
50
- end
51
- end
52
-
53
- describe ".edit" do
54
-
55
- before do
56
- domain = @response.domains.first
57
- record = subject.all(domain.id).first
58
- @response_create = subject.edit(domain.id, record.id, { data: '@' })
59
- end
60
-
61
- context "default" do
62
- it do
63
- @response_create.status.should eq ok
64
- end
65
- end
66
- end
67
-
68
- describe ".destroy" do
69
-
70
- before do
71
- domain = @response.domains.first
72
- record = subject.all(domain.id).first@response_create = subject.create(domain_name, droplet.ip_address)
73
- @response_destroy = subject.destroy(domain.id, record.id)
74
- end
75
-
76
- context "default" do
77
- it do
78
- @response_destroy.status.should eq ok
79
- end
80
- end
81
- end
62
+ describe "._destroy" do
63
+ let(:domain_id) { "100" }
64
+ let(:record_id) { "50" }
65
+
66
+ before do
67
+ @url = subject._destroy(domain_id, record_id)
68
+ end
82
69
 
70
+ it do
71
+ @url.should eq "https://api.digitalocean.com/domains/#{domain_id}/records/#{record_id}/destroy?client_id=client_id_required&api_key=api_key_required"
83
72
  end
84
73
  end
85
- end
74
+ end
@@ -1,24 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Digitalocean::Region do
4
- let(:ok) { "OK" }
5
4
  let(:subject) { Digitalocean::Region }
6
5
 
7
- context "correct api key" do
6
+ describe "._all" do
8
7
  before do
9
- set_client_id_and_api_key!
8
+ @url = subject._all
10
9
  end
11
10
 
12
- describe ".all" do
13
- before do
14
- @response = subject.all
15
- end
16
-
17
- context "default" do
18
- it do
19
- @response.status.should eq ok
20
- end
21
- end
11
+ it do
12
+ @url.should eq "https://api.digitalocean.com/regions/?client_id=client_id_required&api_key=api_key_required"
22
13
  end
23
14
  end
24
- end
15
+ end