stealth 2.0.0.beta3 → 2.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7769a4954530dd2ea5b68d22a05488423d66e464f9ef5863eb26b58a9a8441e
4
- data.tar.gz: 10b939107c4df107172d64fb14f2e4406ad50597841e2eb76ebe4f31f4eb9f73
3
+ metadata.gz: c7c4304b177d264b2f7179e5bad5c8bf509421a386f0d9ec66d4c7c53c4c1972
4
+ data.tar.gz: fdcd30455510aef62945bce7716e06559c3b2eb0105b4199ba5c8c99e201b60f
5
5
  SHA512:
6
- metadata.gz: 7c4aa16fb304ac4a9b78c5ab470b19a93bf2ea085fb767bc73d3cb6f73a6ce25b065242d933fc7d6635c8411dd2e7e8b1e538912fe521a5c9b8a81ffc9225473
7
- data.tar.gz: ad6ae7e02a9c8e2c1f10732ad368d6eafbab698c361d3003bd2a0e8faacf3c6188de100d2bbc09577ac61546b98c1c66f3faa2af03b0d73f1f18a4d9d41c2ab4
6
+ metadata.gz: d0aa0623fcc9978fd62a31fbe863fa1e143427431f125e144f97967cf9792ba37f0779e3fae826647eccc3726633fbb61ff7ae2c2b9f82580a3d890ca92c3174
7
+ data.tar.gz: a64cfaa6e32319b28dc2bebe0ad6626c0c8e482de0ac13bbcf0f46c5b73cc71121d06535ed91ed6e11afe65bcc5859cc7bb4076494715755f0468227a86ca077
data/CHANGELOG.md CHANGED
@@ -42,7 +42,7 @@
42
42
  * [Controllers] `normalized_msg` and `homophone_translated_msg` are now memoized for performance.
43
43
  * [Errors] `Stealth::Errors::MessageNotRecognized` has been renamed to `Stealth::Errors::UnrecognizedMessage`
44
44
  * [Controllers] When `handle_message` or `get_match` raise a `Stealth::Errors::UnrecognizedMessage`, the user is first routed to a new `UnrecognizedMessagesController` to perform NLP. If that controller fails to match, the `catch_all` is run as normal.
45
- * [Errors] Client errors now call respective BotController actions: `handle_opt_out` and `handle_invalid_session_id`. Each client is responsible for raising `Stealth::Errors::UserOptOut` or `Stealth::Errors::InvalidSessionId` errors.
45
+ * [Errors] Client errors now call respective BotController actions: `handle_opt_out`, `handle_invalid_session_id`, `handle_message_filtered`, `handle_unknown_error`. Each client is responsible for raising `Stealth::Errors::UserOptOut`, `Stealth::Errors::InvalidSessionId`, `Stealth::Errors::MessageFiltered`, `Stealth::Errors::UnknownError` errors, respectively.
46
46
  * [Controllers] `handle_message` and `get_match` now detect homophones for alpha ordinals (A-Z)
47
47
  * [Controllers] `handle_message` and `get_match` now ignore single and double quotes for alpha-ordinals
48
48
  * [CoreExt] Strings now have a `normalize` method for removing padding and quotes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stealth (2.0.0.beta3)
4
+ stealth (2.0.0.beta4)
5
5
  activesupport (~> 6.0)
6
6
  multi_json (~> 1.12)
7
7
  puma (>= 4.2, < 6.0)
@@ -12,7 +12,7 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activesupport (6.1.4.1)
15
+ activesupport (6.1.4.6)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 1.6, < 2)
18
18
  minitest (>= 5.1)
@@ -21,23 +21,23 @@ GEM
21
21
  concurrent-ruby (1.1.9)
22
22
  connection_pool (2.2.5)
23
23
  diff-lcs (1.3)
24
- i18n (1.8.11)
24
+ i18n (1.10.0)
25
25
  concurrent-ruby (~> 1.0)
26
- minitest (5.14.4)
26
+ minitest (5.15.0)
27
27
  mock_redis (0.23.0)
28
28
  multi_json (1.15.0)
29
29
  mustermann (1.1.1)
30
30
  ruby2_keywords (~> 0.0.1)
31
31
  nio4r (2.5.8)
32
32
  oj (3.10.6)
33
- puma (5.5.2)
33
+ puma (5.6.2)
34
34
  nio4r (~> 2.0)
35
35
  rack (2.2.3)
36
- rack-protection (2.1.0)
36
+ rack-protection (2.2.0)
37
37
  rack
38
38
  rack-test (1.1.0)
39
39
  rack (>= 1.0, < 3)
40
- redis (4.5.1)
40
+ redis (4.6.0)
41
41
  rspec (3.9.0)
42
42
  rspec-core (~> 3.9.0)
43
43
  rspec-expectations (~> 3.9.0)
@@ -54,20 +54,20 @@ GEM
54
54
  rspec_junit_formatter (0.4.1)
55
55
  rspec-core (>= 2, < 4, != 2.12.0)
56
56
  ruby2_keywords (0.0.5)
57
- sidekiq (6.3.1)
57
+ sidekiq (6.4.1)
58
58
  connection_pool (>= 2.2.2)
59
59
  rack (~> 2.0)
60
60
  redis (>= 4.2.0)
61
- sinatra (2.1.0)
61
+ sinatra (2.2.0)
62
62
  mustermann (~> 1.0)
63
63
  rack (~> 2.2)
64
- rack-protection (= 2.1.0)
64
+ rack-protection (= 2.2.0)
65
65
  tilt (~> 2.0)
66
- thor (1.1.0)
66
+ thor (1.2.1)
67
67
  tilt (2.0.10)
68
68
  tzinfo (2.0.4)
69
69
  concurrent-ruby (~> 1.0)
70
- zeitwerk (2.5.1)
70
+ zeitwerk (2.5.4)
71
71
 
72
72
  PLATFORMS
73
73
  ruby
data/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  Stealth is a Ruby framework for creating text and voice chatbots. It's design is inspired by Ruby on Rails's philosophy of convention over configuration. It has an MVC architecture with the slight caveat that `views` are aptly named `replies`.
4
4
 
5
- [![CircleCI](https://circleci.com/gh/hellostealth/stealth.svg?style=svg)](https://circleci.com/gh/hellostealth/stealth)
5
+ ![CircleCI](https://img.shields.io/circleci/build/github/hellostealth/stealth?style=for-the-badge)
6
+ ![Gem (including prereleases)](https://img.shields.io/gem/v/stealth?include_prereleases&style=for-the-badge)
6
7
 
7
8
  ## Features
8
9
 
@@ -37,6 +38,7 @@ Currently, there are gems for:
37
38
  * [Alexa Skill](https://github.com/hellostealth/stealth-alexa) (Early alpha)
38
39
 
39
40
  ### Natural Language Processing
41
+ * [Microsoft LUIS](https://github.com/hellostealth/stealth-luis)
40
42
  * [AWS Comprehend](https://github.com/hellostealth/stealth-aws-comprehend)
41
43
 
42
44
  ### Analytics
@@ -52,4 +54,4 @@ Stealth is versioned using [Semantic Versioning](https://semver.org), but it's m
52
54
 
53
55
  ## License
54
56
 
55
- "Stealth" and the Stealth logo are Copyright (c) 2020 Mauricio Gomes
57
+ "Stealth" and the Stealth logo are Copyright (c) 2017-2022 MAV Automated Ventures Inc.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.beta3
1
+ 2.0.0.beta4
@@ -33,10 +33,32 @@ module Stealth
33
33
  begin
34
34
  send_reply(reply: reply)
35
35
  rescue Stealth::Errors::UserOptOut => e
36
- user_opt_out_handler(msg: e.message)
36
+ msg = "User #{current_session_id} opted out. [#{e.message}]"
37
+ service_error_dispatcher(
38
+ handler_method: :handle_opt_out,
39
+ error_msg: msg
40
+ )
37
41
  return
38
42
  rescue Stealth::Errors::InvalidSessionID => e
39
- invalid_session_id_handler(msg: e.message)
43
+ msg = "User #{current_session_id} has an invalid session_id. [#{e.message}]"
44
+ service_error_dispatcher(
45
+ handler_method: :handle_invalid_session_id,
46
+ error_msg: msg
47
+ )
48
+ return
49
+ rescue Stealth::Errors::MessageFiltered => e
50
+ msg = "Message to user #{current_session_id} was filtered. [#{e.message}]"
51
+ service_error_dispatcher(
52
+ handler_method: :handle_message_filtered,
53
+ error_msg: msg
54
+ )
55
+ return
56
+ rescue Stealth::Errors::UnknownServiceError => e
57
+ msg = "User #{current_session_id} had an unknown error. [#{e.message}]"
58
+ service_error_dispatcher(
59
+ handler_method: :handle_unknown_error,
60
+ error_msg: msg
61
+ )
40
62
  return
41
63
  end
42
64
 
@@ -211,35 +233,17 @@ module Stealth
211
233
  return file_contents, selected_preprocessor
212
234
  end
213
235
 
214
- def user_opt_out_handler(msg:)
215
- if self.respond_to?(:handle_opt_out, true)
216
- self.send(:handle_opt_out)
217
- Stealth::Logger.l(
218
- topic: current_service,
219
- message: "User #{current_session_id} opted out. [#{msg}]"
220
- )
221
- else
222
- Stealth::Logger.l(
223
- topic: :err,
224
- message: "User #{current_session_id} unhandled exception due to opt-out."
225
- )
226
- end
227
-
228
- do_nothing
229
- end
230
-
231
- def invalid_session_id_handler(msg:)
232
- if self.respond_to?(:handle_invalid_session_id, true)
233
- self.send(:handle_invalid_session_id)
236
+ def service_error_dispatcher(handler_method:, error_msg:)
237
+ if self.respond_to?(handler_method, true)
234
238
  Stealth::Logger.l(
235
239
  topic: current_service,
236
- message: "User #{current_session_id} has an invalid session_id. [#{msg}]"
240
+ message: error_msg
237
241
  )
242
+ self.send(handler_method)
238
243
  else
239
244
  Stealth::Logger.l(
240
245
  topic: :err,
241
- message: "User #{current_session_id} unhandled exception due to an " \
242
- "invalid session_id. [#{msg}]"
246
+ message: "Unhandled service exception for user #{current_session_id}. No error handler for `#{handler_method}` found."
243
247
  )
244
248
  end
245
249
 
@@ -43,12 +43,20 @@ module Stealth
43
43
  class FlowDefinitionError < Errors
44
44
  end
45
45
 
46
+ # Service errors
46
47
  class InvalidSessionID < Errors
47
48
  end
48
49
 
49
50
  class UserOptOut < Errors
50
51
  end
51
52
 
53
+ class MessageFiltered < Errors
54
+ end
55
+
56
+ class UnknownServiceError < Errors
57
+ end
58
+
59
+ # Homophone errors
52
60
  class ReservedHomophoneUsed < Errors
53
61
  end
54
62
 
@@ -40,16 +40,28 @@ private
40
40
  end
41
41
 
42
42
  # Automatically called when clients receive an opt-out error from
43
- # the platform. You can write your own steps for handling.
43
+ # the platform. You may write your own steps for handling.
44
44
  def handle_opt_out
45
45
  do_nothing
46
46
  end
47
47
 
48
48
  # Automatically called when clients receive an invalid session_id error from
49
49
  # the platform. For example, attempting to text a landline.
50
- # You can write your own steps for handling.
50
+ # You may write your own steps for handling.
51
51
  def handle_invalid_session_id
52
52
  do_nothing
53
53
  end
54
54
 
55
+ # Automatically called when a transmitted message is filtered/marked as spam.
56
+ # You may write your own steps for handling.
57
+ def handle_message_filtered
58
+ do_nothing
59
+ end
60
+
61
+ # Automatically called when an unknown error is returned by the platform.
62
+ # You may write your own steps for handling.
63
+ def handle_unknown_error
64
+ do_nothing
65
+ end
66
+
55
67
  end
data/logo.svg CHANGED
@@ -1 +1,28 @@
1
- <svg viewBox="0 0 92 95.79" xmlns="http://www.w3.org/2000/svg"><g fill="#000a38"><path d="m5.63 92.27a1.69 1.69 0 0 0 1.79 1.15c.88 0 1.49-.38 1.49-1.08 0-.53-.34-.77-1-.94l-2.17-.4c-1.62-.37-2.84-1.23-2.84-3.14 0-2.21 1.8-3.66 4.25-3.66 2.7 0 4.23 1.51 4.53 3.45h-2.82a1.66 1.66 0 0 0 -1.7-1.1c-.82 0-1.38.37-1.38 1s.34.78.92.9l2.16.52c1.89.46 2.93 1.5 2.93 3.25 0 2.31-1.91 3.63-4.32 3.63-2.65 0-4.45-1.3-4.84-3.52z"/><path d="m14.72 84.34h9.73v2.53h-3.45v8.74h-2.87v-8.74h-3.41z"/><path d="m35.88 84.34v2.53h-5.06v1.76h4.62v2.48h-4.62v2h5.06v2.55h-7.88v-11.32z"/><path d="m46.12 84.34 4.21 11.27h-2.94l-.79-2.19h-4l-.78 2.19h-2.82l4.21-11.27zm-2.65 6.66h2.27l-1.14-3.18z"/><path d="m53.62 84.34h2.9v8.72h4.95v2.55h-7.85z"/><path d="m63 84.34h9.72v2.53h-3.4v8.74h-2.9v-8.74h-3.42z"/><path d="m86.33 84.34v11.27h-2.9v-4.46h-4.27v4.46h-2.9v-11.27h2.9v4.27h4.27v-4.27z"/><path d="m92 46-14.84-14.84-1.48-1.48-13.36-13.36-1.48-1.48-14.84-14.84-14.84 14.84-1.48 1.48-13.36 13.36-1.48 1.48-14.84 14.84 16.32 16.32 14.84-14.84 14.84 14.84 14.84-14.84 14.84 14.84zm-31.16-28.19 13.35 13.35-6.67 6.68-6.68 6.68-13.36-13.36 6.68-6.68zm-14.84-14.81 13.36 13.32-6.68 6.68-6.68 6.68-6.68-6.68-6.68-6.68zm-28.19 28.16 13.35-13.35 6.68 6.67 6.68 6.68-13.36 13.36-6.68-6.68zm-1.49 28.2-13.32-13.36 13.32-13.36 6.68 6.68 6.68 6.68zm29.68 0-13.36-13.36 13.36-13.36 13.36 13.36zm23-20 6.68-6.68 13.32 13.32-13.32 13.36-13.36-13.36z"/></g></svg>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="180px" height="180px" viewBox="0 0 180 180" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>stealth_app_logo</title>
4
+ <defs>
5
+ <rect id="path-1" x="0" y="0" width="180" height="180"></rect>
6
+ <path d="M51.3778558,-2.07572687e-15 L128.622144,2.07572687e-15 C146.487344,-1.20605709e-15 152.965697,1.86013822 159.496947,5.35308895 C166.028197,8.84603967 171.15396,13.9718029 174.646911,20.5030529 C178.139862,27.0343029 180,33.512656 180,51.3778558 L180,128.622144 C180,146.487344 178.139862,152.965697 174.646911,159.496947 C171.15396,166.028197 166.028197,171.15396 159.496947,174.646911 C152.965697,178.139862 146.487344,180 128.622144,180 L51.3778558,180 C33.512656,180 27.0343029,178.139862 20.5030529,174.646911 C13.9718029,171.15396 8.84603967,166.028197 5.35308895,159.496947 C1.86013822,152.965697 8.04038057e-16,146.487344 -1.38381791e-15,128.622144 L1.38381791e-15,51.3778558 C-8.04038057e-16,33.512656 1.86013822,27.0343029 5.35308895,20.5030529 C8.84603967,13.9718029 13.9718029,8.84603967 20.5030529,5.35308895 C27.0343029,1.86013822 33.512656,1.20605709e-15 51.3778558,-2.07572687e-15 Z" id="path-3"></path>
7
+ </defs>
8
+ <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
9
+ <g id="icon@180">
10
+ <g id="icon">
11
+ <mask id="mask-2" fill="white">
12
+ <use xlink:href="#path-1"></use>
13
+ </mask>
14
+ <g id="Mask"></g>
15
+ <g id="Rectangle" mask="url(#mask-2)">
16
+ <mask id="mask-4" fill="white">
17
+ <use xlink:href="#path-3"></use>
18
+ </mask>
19
+ <use id="Mask" fill="#FFFFFF" xlink:href="#path-3"></use>
20
+ </g>
21
+ </g>
22
+ <g id="logo" transform="translate(24.960938, 18.984375)" fill="#000A38">
23
+ <path d="M65.0390625,0 L44.0583093,20.9046079 L41.9615065,22.9953504 L23.077556,41.8106246 L20.9807532,43.9013672 L0,64.8073839 L23.077556,87.8027344 L44.0583093,66.8967176 L65.0390625,87.8027344 L86.0198157,66.8967176 L106.999155,87.8027344 L130.078125,64.8073839 L109.098786,43.9013672 L106.999155,41.8106246 L88.1180324,22.9953504 L86.0198157,20.9046079 L65.0390625,0 Z M55.5970873,32.403692 L46.156526,22.9953504 L65.0390625,4.18007626 L83.921599,22.9953504 L74.4810377,32.403692 L65.0390625,41.8106246 L55.5970873,32.403692 Z M67.1372792,43.9013672 L76.5778405,34.4944345 L86.0198157,25.086093 L104.902352,43.9013672 L95.460377,53.3097087 L86.0198157,62.7166414 L67.1372792,43.9013672 Z M34.617748,53.3097087 L25.1771867,43.9013672 L44.0583093,25.086093 L53.5002845,34.4944345 L62.9408458,43.9013672 L44.0583093,62.7166414 L34.617748,53.3097087 Z M88.1180324,64.8073839 L97.5585938,55.3990424 L106.999155,45.9921097 L125.883105,64.8073839 L106.999155,83.6226581 L88.1180324,64.8073839 Z M46.156526,64.8073839 L65.0390625,45.9921097 L83.921599,64.8073839 L65.0390625,83.6226581 L46.156526,64.8073839 Z M4.19501953,64.8073839 L23.077556,45.9921097 L32.5195313,55.3990424 L41.9615065,64.8073839 L23.077556,83.6226581 L4.19501953,64.8073839 Z" id="glyph"></path>
24
+ <path d="M7.93868906,127.899703 C11.7243984,127.899703 14.7190641,125.865591 14.7190641,122.305894 C14.7190641,119.621995 13.0804734,118.011656 10.1140594,117.305367 L6.72387188,116.514323 C5.81982188,116.316562 5.28304219,115.892789 5.28304219,115.129997 C5.28304219,114.169444 6.15884063,113.604412 7.4584125,113.604412 C8.95574531,113.604412 9.74678906,114.338953 10.1140594,115.299506 L14.5495547,115.299506 C14.0692781,112.304841 11.6678953,109.988213 7.43016094,109.988213 C3.58794844,109.988213 0.762792188,112.220086 0.762792188,115.610273 C0.762792188,118.548436 2.68389844,119.876259 5.22653906,120.441291 L8.56022344,121.14758 C9.66203438,121.401844 10.1988141,121.769114 10.1988141,122.588409 C10.1988141,123.661969 9.23826094,124.255252 7.85393438,124.255252 C6.44135625,124.255252 5.4243,123.661969 5.05702969,122.475403 L0.33901875,122.475403 C0.960553125,125.893842 3.78570938,127.899703 7.93868906,127.899703 Z M28.539987,127.617187 L28.539987,114.169444 L33.9077839,114.169444 L33.9077839,110.270728 L18.6519401,110.270728 L18.6519401,114.169444 L23.9914855,114.169444 L23.9914855,127.617187 L28.539987,127.617187 Z M51.1753975,127.617187 L51.1753975,123.69022 L43.2367084,123.69022 L43.2367084,120.695555 L50.49736,120.695555 L50.49736,116.881594 L43.2367084,116.881594 L43.2367084,114.169444 L51.1753975,114.169444 L51.1753975,110.270728 L38.7729615,110.270728 L38.7729615,127.617187 L51.1753975,127.617187 Z M59.8262845,127.617187 L61.0411017,124.255252 L67.3412001,124.255252 L68.5842689,127.617187 L73.1892736,127.617187 L66.5784079,110.270728 L61.9451517,110.270728 L55.3342861,127.617187 L59.8262845,127.617187 Z M65.9851251,120.526045 L62.4254283,120.526045 L64.2052767,115.638525 L65.9851251,120.526045 Z M90.0048622,127.617187 L90.0048622,123.69022 L82.2356825,123.69022 L82.2356825,110.270728 L77.6871809,110.270728 L77.6871809,127.617187 L90.0048622,127.617187 Z M101.650415,127.617187 L101.650415,114.169444 L107.018212,114.169444 L107.018212,110.270728 L91.7623679,110.270728 L91.7623679,114.169444 L97.1019132,114.169444 L97.1019132,127.617187 L101.650415,127.617187 Z M116.431891,127.617187 L116.431891,120.752058 L123.127511,120.752058 L123.127511,127.617187 L127.676013,127.617187 L127.676013,110.270728 L123.127511,110.270728 L123.127511,116.853342 L116.431891,116.853342 L116.431891,110.270728 L111.883389,110.270728 L111.883389,127.617187 L116.431891,127.617187 Z" id="STEALTH" fill-rule="nonzero"></path>
25
+ </g>
26
+ </g>
27
+ </g>
28
+ </svg>
@@ -632,7 +632,7 @@ describe "Stealth::Controller replies" do
632
632
  it "should log the unhandled exception if the controller does not have a handle_opt_out method" do
633
633
  expect(Stealth::Logger).to receive(:l).with(
634
634
  topic: :err,
635
- message: "User #{facebook_message.sender_id} unhandled exception due to opt-out."
635
+ message: "Unhandled service exception for user #{facebook_message.sender_id}. No error handler for `handle_opt_out` found."
636
636
  )
637
637
  expect(controller).to receive(:do_nothing)
638
638
  controller.say_offer
@@ -659,7 +659,7 @@ describe "Stealth::Controller replies" do
659
659
  it "should log the unhandled exception if the controller does not have a handle_invalid_session_id method" do
660
660
  expect(Stealth::Logger).to receive(:l).with(
661
661
  topic: :err,
662
- message: "User #{facebook_message.sender_id} unhandled exception due to an invalid session_id. [boom]"
662
+ message: "Unhandled service exception for user #{facebook_message.sender_id}. No error handler for `handle_invalid_session_id` found."
663
663
  )
664
664
  expect(controller).to receive(:do_nothing)
665
665
  controller.say_offer
@@ -676,6 +676,60 @@ describe "Stealth::Controller replies" do
676
676
  end
677
677
  end
678
678
 
679
+ describe "Stealth::Errors::MessageFiltered" do
680
+ before(:each) do
681
+ expect(stubbed_client).to receive(:transmit).and_raise(
682
+ Stealth::Errors::MessageFiltered.new('boom')
683
+ ).once # Retuns early; doesn't send the remaining replies in the file
684
+ end
685
+
686
+ it "should log the unhandled exception if the controller does not have a handle_message_filtered method" do
687
+ expect(Stealth::Logger).to receive(:l).with(
688
+ topic: :err,
689
+ message: "Unhandled service exception for user #{facebook_message.sender_id}. No error handler for `handle_message_filtered` found."
690
+ )
691
+ expect(controller).to receive(:do_nothing)
692
+ controller.say_offer
693
+ end
694
+
695
+ it "should call handle_message_filtered method" do
696
+ expect(controller).to receive(:handle_message_filtered)
697
+ expect(Stealth::Logger).to receive(:l).with(
698
+ topic: 'facebook',
699
+ message: "Message to user #{facebook_message.sender_id} was filtered. [boom]"
700
+ )
701
+ expect(controller).to receive(:do_nothing)
702
+ controller.say_offer
703
+ end
704
+ end
705
+
706
+ describe "Stealth::Errors::UnknownServiceError" do
707
+ before(:each) do
708
+ expect(stubbed_client).to receive(:transmit).and_raise(
709
+ Stealth::Errors::UnknownServiceError.new('boom')
710
+ ).once # Retuns early; doesn't send the remaining replies in the file
711
+ end
712
+
713
+ it "should log the unhandled exception if the controller does not have a handle_unknown_error method" do
714
+ expect(Stealth::Logger).to receive(:l).with(
715
+ topic: :err,
716
+ message: "Unhandled service exception for user #{facebook_message.sender_id}. No error handler for `handle_unknown_error` found."
717
+ )
718
+ expect(controller).to receive(:do_nothing)
719
+ controller.say_offer
720
+ end
721
+
722
+ it "should call handle_unknown_error method" do
723
+ expect(controller).to receive(:handle_unknown_error)
724
+ expect(Stealth::Logger).to receive(:l).with(
725
+ topic: 'facebook',
726
+ message: "User #{facebook_message.sender_id} had an unknown error. [boom]"
727
+ )
728
+ expect(controller).to receive(:do_nothing)
729
+ controller.say_offer
730
+ end
731
+ end
732
+
679
733
  describe 'an unknown client error' do
680
734
  before(:each) do
681
735
  allow(stubbed_client).to receive(:transmit).and_raise(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stealth
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta3
4
+ version: 2.0.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio Gomes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-12-05 00:00:00.000000000 Z
12
+ date: 2022-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra