Skip to content

Commit 885dbaf

Browse files
authored
Merge pull request #272 from mailjet/DE-1590
DE-1590: Fix specs
2 parents 14d7bd3 + 7e90dd5 commit 885dbaf

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

lib/mailjet/exception/errors.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ def initialize(message = nil, response = nil)
5555
end
5656

5757
api_message = begin
58-
Yajl::Parser.parse(response.response_body)['ErrorMessage']
58+
if response.response_body.present?
59+
Yajl::Parser.parse(response.response_body)['ErrorMessage']
60+
else
61+
'Unauthorized'
62+
end
5963
rescue Yajl::ParseError
6064
response.response_body
6165
rescue NoMethodError

spec/resources/resource_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
RSpec.describe Mailjet::Resource, :vcr do
44
context '/invalid_credentials' do
55
it 'should raise api connection error' do
6-
expect{ Mailjet::Apikey.first }.to raise_error(Mailjet::Unauthorized, /the server responded with status 401 - Invalid Domain or API key/)
6+
expect{ Mailjet::Apikey.first }.to raise_error(Mailjet::Unauthorized, /Invalid Domain or API key: Unauthorized/)
77
end
88
end
99

spec/resources/send_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
}]
6969
}
7070

71-
expect{ described_class.create(message, version: 'v3.1') }.to raise_error(Mailjet::Unauthorized, /the server responded with status 401 - Invalid Domain or API key/)
71+
expect{ described_class.create(message, version: 'v3.1') }.to raise_error(Mailjet::Unauthorized, /Visit API keys management section to check your keys/)
7272
end
7373
end
7474
end

0 commit comments

Comments
 (0)