spec/integration/errors_spec.rb in currency_cloud-0.5 vs spec/integration/errors_spec.rb in currency_cloud-0.7
- old
+ new
@@ -8,10 +8,44 @@
CurrencyCloud.login_id = 'rjnienaber@gmail.com'
CurrencyCloud.api_key = 'ef0fd50fca1fb14c1fab3a8436b9ecb65f02f129fd87eafa45ded8ae257528f0'
CurrencyCloud.token = nil
end
+ it 'contains full details for api error' do
+ CurrencyCloud.login_id = 'non-existent-login-id'
+ CurrencyCloud.api_key = 'ef0fd50fca1fb14c1fab3a8436b9ecb57528f0'
+
+ error = nil
+ begin
+ CurrencyCloud.session
+ raise 'Should have failed'
+ rescue CurrencyCloud::BadRequestError => error
+ end
+
+ expected_error = %Q{CurrencyCloud::BadRequestError
+---
+platform: #{error.platform}
+request:
+ parameters:
+ login_id: non-existent-login-id
+ api_key: ef0fd50fca1fb14c1fab3a8436b9ecb57528f0
+ verb: post
+ url: https://devapi.thecurrencycloud.com/v2/authenticate/api
+response:
+ status_code: 400
+ date: Wed, 29 Apr 2015 22:46:53 GMT
+ request_id: 2775253392756800903
+errors:
+- field: api_key
+ code: api_key_length_is_invalid
+ message: api_key should be 64 character(s) long
+ params:
+ length: 64
+}
+ expect(error.to_s).to eq(expected_error)
+ end
+
it 'is raised on a bad request' do
CurrencyCloud.login_id = 'non-existent-login-id'
CurrencyCloud.api_key = 'ef0fd50fca1fb14c1fab3a8436b9ecb57528f0'
error = nil
@@ -64,9 +98,22 @@
CurrencyCloud.session
raise 'Should have failed'
rescue CurrencyCloud::UnexpectedError => error
end
+ expected_error = %Q{CurrencyCloud::UnexpectedError
+---
+platform: #{error.platform}
+request:
+ parameters:
+ login_id: rjnienaber@gmail.com
+ api_key: ef0fd50fca1fb14c1fab3a8436b9ecb65f02f129fd87eafa45ded8ae257528f0
+ verb: post
+ url: https://devapi.thecurrencycloud.com/v2/authenticate/api
+inner_error: Timeout::Error
+}
+
+ expect(error.to_s).to eq(expected_error)
expect(error.inner_error).to_not be_nil
expect(error.inner_error.class).to eq(Timeout::Error)
end
it 'is raised on a forbidden request' do
\ No newline at end of file