tddium_client 0.0.12 → 0.1.0
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.
- data/lib/tddium_client.rb +11 -0
- data/lib/tddium_client/version.rb +1 -1
- data/spec/tddium_client_spec.rb +13 -0
- metadata +1 -1
data/lib/tddium_client.rb
CHANGED
@@ -51,6 +51,7 @@ module TddiumClient
|
|
51
51
|
def initialize(http_response)
|
52
52
|
super
|
53
53
|
raise TddiumClient::Error::Server.new(http_response) unless tddium_response.include?("status")
|
54
|
+
raise TddiumClient::Error::UpgradeRequired.new(http_response) if http_response.code == 426
|
54
55
|
raise TddiumClient::Error::API.new(http_response) unless tddium_response["status"] == 0
|
55
56
|
end
|
56
57
|
end
|
@@ -90,6 +91,16 @@ module TddiumClient
|
|
90
91
|
tddium_response["status"]
|
91
92
|
end
|
92
93
|
end
|
94
|
+
|
95
|
+
class UpgradeRequired < API
|
96
|
+
def initialize(http_response)
|
97
|
+
super
|
98
|
+
end
|
99
|
+
|
100
|
+
def message
|
101
|
+
"API Error: #{explanation}"
|
102
|
+
end
|
103
|
+
end
|
93
104
|
end
|
94
105
|
|
95
106
|
class InternalClient
|
data/spec/tddium_client_spec.rb
CHANGED
@@ -194,6 +194,19 @@ describe "TddiumClient" do
|
|
194
194
|
|
195
195
|
end
|
196
196
|
end
|
197
|
+
|
198
|
+
describe "UpgradeRequired" do
|
199
|
+
before do
|
200
|
+
stub_http_code(426) # Upgrade required
|
201
|
+
stub_sample_api_response(:success => false, :explanation => "You need to upgrade")
|
202
|
+
end
|
203
|
+
|
204
|
+
let (:upgrade_required) { TddiumClient::Error::UpgradeRequired.new(http_response) }
|
205
|
+
|
206
|
+
it "should print the explanation" do
|
207
|
+
upgrade_required.message.should == "API Error: You need to upgrade"
|
208
|
+
end
|
209
|
+
end
|
197
210
|
end
|
198
211
|
|
199
212
|
describe "InternalClient" do
|