Skip to content

Commit e520fa2

Browse files
committed
Raise an error when Help Scout does something the gem does not support
1 parent 659f106 commit e520fa2

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/help_scout.rb

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
class HelpScout
55
class ValidationError < StandardError; end
6+
class NotImplementedError < StandardError; end
67

78
HTTP_CREATED = 201
89
HTTP_BAD_REQUEST = 400
@@ -30,6 +31,8 @@ def create_conversation(data)
3031
elsif last_response.code == HTTP_BAD_REQUEST
3132
# Validation failed so return the errors
3233
raise ValidationError, last_response.parsed_response["message"]
34+
else
35+
raise NotImplementedError, "Help Scout returned something that is not implemented by the help_scout gem yet. Sorry."
3336
end
3437
end
3538

spec/helpscout_spec.rb

+14
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@
3636
expect { client.create_conversation(data) }.to raise_error(HelpScout::ValidationError, "Email is not valid")
3737
end
3838
end
39+
40+
context 'with a not implemented status code' do
41+
it 'returns a not implemented error' do
42+
data = { subject: "Help me!" }
43+
44+
url = 'https://api.helpscout.net/v1/conversations.json'
45+
stub_request(:post, url).
46+
to_return(
47+
status: 500,
48+
)
49+
50+
expect { client.create_conversation(data) }.to raise_error(HelpScout::NotImplementedError)
51+
end
52+
end
3953
end
4054

4155
describe '#search_conversations' do

0 commit comments

Comments
 (0)