atlantic_net 0.1.2 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f11c5b0a4d7a3fa1b38dfebec04ff9426433a5a
4
- data.tar.gz: d4458c00fd3b5ab52f232090be26444e72c925eb
3
+ metadata.gz: 1bb1ba38e0443eb7a881aa71d242200c1ab2ca96
4
+ data.tar.gz: 2939633312aae05b31ec72a159a6abd40f547c10
5
5
  SHA512:
6
- metadata.gz: 235396cac8f1bb392921918f60848927fe6c8a738cd27a58776bf0cecb2ffdc41b696f0a67ddd7d350e163bd34cdbe2dda1fef5c1f2863ccd1fae9fd676949b7
7
- data.tar.gz: 76af83ddec3aac53a6415c3bd92fffc760372d4edd5d92cd7263092baa1593f6adeac88dcc71b85a243fb93fec92c5f5c71e60061948b4fa7a0c6406f4f1bc27
6
+ metadata.gz: 492053e8f827e1a7f762f5eb9541a7f8ce1d41b7470f92faac17de9f4a1f22fdd2e0a108dc6b2b84dec45743aff8baadd2b39ff15bec5b348f3c7f8ef71f35ab
7
+ data.tar.gz: 280d48b1c4ea75555ea66ce0b9efc2e320f68d4d495f6f7dce36936cd944529d99cf43835388047920fc8e8ac38c00f7eefa1fea875a6fe7c76d8c2b380d6fd5
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "atlantic_net"
3
- spec.version = "0.1.2"
3
+ spec.version = "0.1.3"
4
4
  spec.authors = ["Jamie Starke"]
5
5
  spec.email = ["git@jamiestarke.com"]
6
6
  spec.description = "A Ruby wrapper of the Atlantic.net API"
@@ -101,7 +101,12 @@ class AtlanticNet
101
101
  def reboot_instance(instance_id, options={})
102
102
  reboot_type = options[:reboot_type] || "soft"
103
103
  response = api_call('reboot-instance', {instanceid: instance_id, reboottype: reboot_type})
104
- response["reboot-instanceresponse"]["return"]
104
+ reboot_response = response["reboot-instanceresponse"]
105
+ if reboot_response.has_key? "return"
106
+ response["reboot-instanceresponse"]["return"]
107
+ else
108
+ response["reboot-instanceresponse"]["instancesSet"]["item"]
109
+ end
105
110
  end
106
111
 
107
112
  # Describe a specific cloud server.
@@ -142,18 +142,6 @@ describe AtlanticNet do
142
142
 
143
143
  describe '#reboot_instance' do
144
144
  let(:instance_id) { "234" }
145
- let(:sample_api_response) {
146
- {
147
- "Timestamp" => 1440171938,
148
- "reboot-instanceresponse" => {
149
- "requestid" => "6723430f-c416-46de-a03d-2d2ea38d3af7",
150
- "return" => {
151
- "Message" => "Successfully queued for reboot",
152
- "value" => "true"
153
- }
154
- }
155
- }
156
- }
157
145
  let(:expected_return) {
158
146
  {
159
147
  "Message" => "Successfully queued for reboot",
@@ -161,27 +149,90 @@ describe AtlanticNet do
161
149
  }
162
150
  }
163
151
 
164
- context "default options" do
165
- let(:reboot_type) { "soft" }
152
+ context "standard documented response" do
153
+ let(:sample_api_response) {
154
+ {
155
+ "Timestamp" => 1440171938,
156
+ "reboot-instanceresponse" => {
157
+ "requestid" => "6723430f-c416-46de-a03d-2d2ea38d3af7",
158
+ "return" => {
159
+ "Message" => "Successfully queued for reboot",
160
+ "value" => "true"
161
+ }
162
+ }
163
+ }
164
+ }
165
+
166
+ context "default options" do
167
+ let(:reboot_type) { "soft" }
168
+
169
+ it 'calls api_call with reboot-instance and instance_id' do
170
+ expect(subject).to receive(:api_call)
171
+ .with("reboot-instance", {instanceid: instance_id, reboottype: reboot_type})
172
+ .and_return(sample_api_response)
173
+ result = subject.reboot_instance(instance_id)
174
+ expect(result).to eq expected_return
175
+ end
176
+ end
166
177
 
167
- it 'calls api_call with reboot-instance and instance_id' do
168
- expect(subject).to receive(:api_call)
169
- .with("reboot-instance", {instanceid: instance_id, reboottype: reboot_type})
170
- .and_return(sample_api_response)
171
- result = subject.reboot_instance(instance_id)
172
- expect(result).to eq expected_return
178
+ context "reboot_type override" do
179
+ let(:reboot_type) { "hard" }
180
+
181
+ it 'calls api_call with reboot-instance, instance_id and reboot_type' do
182
+ expect(subject).to receive(:api_call)
183
+ .with("reboot-instance", {instanceid: instance_id, reboottype: reboot_type})
184
+ .and_return(sample_api_response)
185
+ result = subject.reboot_instance(instance_id, reboot_type: reboot_type)
186
+ expect(result).to eq expected_return
187
+ end
173
188
  end
174
189
  end
175
-
176
- context "reboot_type override" do
177
- let(:reboot_type) { "hard" }
178
190
 
179
- it 'calls api_call with reboot-instance, instance_id and reboot_type' do
180
- expect(subject).to receive(:api_call)
181
- .with("reboot-instance", {instanceid: instance_id, reboottype: reboot_type})
182
- .and_return(sample_api_response)
183
- result = subject.reboot_instance(instance_id, reboot_type: reboot_type)
184
- expect(result).to eq expected_return
191
+ context "actual response" do
192
+ let(:sample_api_response) {
193
+ {
194
+ "reboot-instanceresponse" => {
195
+ "requestid" => "6723430f-c416-46de-a03d-2d2ea38d3af7",
196
+ "instancesSet" => {
197
+ "item" => {
198
+ "value" => "true",
199
+ "Message" => "Successfully queued for reboot",
200
+ "InstanceId" => "234"
201
+ }
202
+ }
203
+ }, "Timestamp" => 1440171938
204
+ }
205
+ }
206
+ let(:expected_return) {
207
+ {
208
+ "Message" => "Successfully queued for reboot",
209
+ "value" => "true",
210
+ "InstanceId" => "234"
211
+ }
212
+ }
213
+
214
+ context "default options" do
215
+ let(:reboot_type) { "soft" }
216
+
217
+ it 'calls api_call with reboot-instance and instance_id' do
218
+ expect(subject).to receive(:api_call)
219
+ .with("reboot-instance", {instanceid: instance_id, reboottype: reboot_type})
220
+ .and_return(sample_api_response)
221
+ result = subject.reboot_instance(instance_id)
222
+ expect(result).to eq expected_return
223
+ end
224
+ end
225
+
226
+ context "reboot_type override" do
227
+ let(:reboot_type) { "hard" }
228
+
229
+ it 'calls api_call with reboot-instance, instance_id and reboot_type' do
230
+ expect(subject).to receive(:api_call)
231
+ .with("reboot-instance", {instanceid: instance_id, reboottype: reboot_type})
232
+ .and_return(sample_api_response)
233
+ result = subject.reboot_instance(instance_id, reboot_type: reboot_type)
234
+ expect(result).to eq expected_return
235
+ end
185
236
  end
186
237
  end
187
238
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atlantic_net
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Starke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-29 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  version: '0'
202
202
  requirements: []
203
203
  rubyforge_project:
204
- rubygems_version: 2.5.1
204
+ rubygems_version: 2.4.6
205
205
  signing_key:
206
206
  specification_version: 4
207
207
  summary: A Ruby wrapper of the Atlantic.net API