lita 3.3.1 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +3 -0
  4. data/lib/lita.rb +45 -97
  5. data/lib/lita/adapter.rb +38 -17
  6. data/lib/lita/adapters/shell.rb +5 -3
  7. data/lib/lita/authorization.rb +109 -60
  8. data/lib/lita/builder.rb +38 -0
  9. data/lib/lita/callback.rb +37 -0
  10. data/lib/lita/cli.rb +2 -0
  11. data/lib/lita/config.rb +1 -18
  12. data/lib/lita/configurable.rb +29 -0
  13. data/lib/lita/configuration.rb +179 -0
  14. data/lib/lita/configuration_validator.rb +66 -0
  15. data/lib/lita/daemon.rb +4 -11
  16. data/lib/lita/default_configuration.rb +146 -0
  17. data/lib/lita/errors.rb +9 -0
  18. data/lib/lita/handler.rb +5 -264
  19. data/lib/lita/handler/chat_router.rb +130 -0
  20. data/lib/lita/handler/common.rb +114 -0
  21. data/lib/lita/handler/event_router.rb +77 -0
  22. data/lib/lita/handler/http_router.rb +26 -0
  23. data/lib/lita/handlers/authorization.rb +13 -18
  24. data/lib/lita/handlers/deprecation_check.rb +24 -0
  25. data/lib/lita/handlers/help.rb +5 -3
  26. data/lib/lita/handlers/info.rb +2 -2
  27. data/lib/lita/http_callback.rb +29 -0
  28. data/lib/lita/http_route.rb +41 -26
  29. data/lib/lita/namespace.rb +23 -0
  30. data/lib/lita/rack_app.rb +29 -2
  31. data/lib/lita/registry.rb +133 -0
  32. data/lib/lita/robot.rb +58 -20
  33. data/lib/lita/route_validator.rb +12 -4
  34. data/lib/lita/rspec.rb +23 -14
  35. data/lib/lita/rspec/handler.rb +93 -23
  36. data/lib/lita/rspec/matchers/chat_route_matcher.rb +48 -0
  37. data/lib/lita/rspec/matchers/deprecated.rb +36 -0
  38. data/lib/lita/rspec/matchers/event_route_matcher.rb +27 -0
  39. data/lib/lita/rspec/matchers/http_route_matcher.rb +18 -60
  40. data/lib/lita/user.rb +0 -6
  41. data/lib/lita/util.rb +1 -8
  42. data/lib/lita/version.rb +1 -1
  43. data/lita.gemspec +1 -0
  44. data/spec/lita/adapter_spec.rb +25 -7
  45. data/spec/lita/adapters/shell_spec.rb +24 -4
  46. data/spec/lita/authorization_spec.rb +57 -38
  47. data/spec/lita/builder_spec.rb +39 -0
  48. data/spec/lita/config_spec.rb +0 -24
  49. data/spec/lita/configuration_spec.rb +222 -0
  50. data/spec/lita/configuration_validator_spec.rb +112 -0
  51. data/spec/lita/daemon_spec.rb +2 -2
  52. data/spec/lita/default_configuration_spec.rb +254 -0
  53. data/spec/lita/handler/chat_router_spec.rb +192 -0
  54. data/spec/lita/handler/common_spec.rb +272 -0
  55. data/spec/lita/handler/event_router_spec.rb +54 -0
  56. data/spec/lita/handler/http_router_spec.rb +106 -0
  57. data/spec/lita/handler_spec.rb +20 -291
  58. data/spec/lita/handlers/authorization_spec.rb +9 -11
  59. data/spec/lita/handlers/deprecation_check_spec.rb +21 -0
  60. data/spec/lita/handlers/help_spec.rb +31 -9
  61. data/spec/lita/handlers/info_spec.rb +2 -2
  62. data/spec/lita/handlers/room_spec.rb +5 -3
  63. data/spec/lita/robot_spec.rb +30 -11
  64. data/spec/lita/rspec_spec.rb +71 -31
  65. data/spec/lita/user_spec.rb +2 -2
  66. data/spec/lita_spec.rb +62 -4
  67. data/spec/spec_helper.rb +7 -0
  68. data/templates/locales/en.yml +56 -4
  69. data/templates/plugin/gemspec.tt +1 -0
  70. data/templates/plugin/spec/spec_helper.tt +4 -0
  71. metadata +54 -8
  72. data/lib/lita/rspec/matchers/event_subscription_matcher.rb +0 -67
  73. data/lib/lita/rspec/matchers/route_matcher.rb +0 -69
  74. data/spec/lita/rack_app_spec.rb +0 -92
@@ -4,10 +4,17 @@ module Lita
4
4
  # registered handlers. Can send outgoing chat messages and set the topic
5
5
  # of chat rooms.
6
6
  class Robot
7
+ extend Forwardable
8
+
7
9
  # A +Rack+ application used for the built-in web server.
8
10
  # @return [Rack::Builder] The +Rack+ app.
9
11
  attr_reader :app
10
12
 
13
+ # The {Authorization} object for the currently running robot.
14
+ # @return [Lita::Authorization] The authorization object.
15
+ # @since 4.0.0
16
+ attr_reader :auth
17
+
11
18
  # The name the robot will look for in incoming messages to determine if it's
12
19
  # being addressed.
13
20
  # @return [String] The mention name.
@@ -22,12 +29,21 @@ module Lita
22
29
  # @return [String] The robot's name.
23
30
  attr_reader :name
24
31
 
25
- def initialize
26
- @name = Lita.config.robot.name
27
- @mention_name = Lita.config.robot.mention_name || @name
28
- @alias = Lita.config.robot.alias
29
- @app = RackApp.new(self)
30
- load_adapter
32
+ # The {Registry} for the currently running robot.
33
+ # @return [Lita::Registry] The registry.
34
+ # @since 4.0.0
35
+ attr_reader :registry
36
+
37
+ def_delegators :registry, :config, :adapters, :handlers, :hooks
38
+
39
+ # @param registry [Lita::Registry] The registry for the robot's configuration and plugins.
40
+ def initialize(registry = Lita)
41
+ @registry = registry
42
+ @name = config.robot.name
43
+ @mention_name = config.robot.mention_name || @name
44
+ @alias = config.robot.alias
45
+ @app = RackApp.build(self)
46
+ @auth = Authorization.new(config)
31
47
  trigger(:loaded)
32
48
  end
33
49
 
@@ -36,7 +52,13 @@ module Lita
36
52
  # @param message [Lita::Message] The incoming message.
37
53
  # @return [void]
38
54
  def receive(message)
39
- Lita.handlers.each { |handler| handler.dispatch(self, message) }
55
+ matched = handlers.map do |handler|
56
+ next unless handler.respond_to?(:dispatch)
57
+
58
+ handler.dispatch(self, message)
59
+ end.any?
60
+
61
+ trigger(:unhandled_message, message: message) unless matched
40
62
  end
41
63
 
42
64
  # Starts the robot, booting the web server and delegating to the adapter to
@@ -44,7 +66,7 @@ module Lita
44
66
  # @return [void]
45
67
  def run
46
68
  run_app
47
- @adapter.run
69
+ adapter.run
48
70
  rescue Interrupt
49
71
  shut_down
50
72
  end
@@ -54,7 +76,7 @@ module Lita
54
76
  # @return [void]
55
77
  # @since 3.0.0
56
78
  def join(room_id)
57
- @adapter.join(room_id)
79
+ adapter.join(room_id)
58
80
  end
59
81
 
60
82
  # Makes the robot part from the room with the specified ID.
@@ -62,7 +84,7 @@ module Lita
62
84
  # @return [void]
63
85
  # @since 3.0.0
64
86
  def part(room_id)
65
- @adapter.part(room_id)
87
+ adapter.part(room_id)
66
88
  end
67
89
 
68
90
  # Sends one or more messages to a user or room.
@@ -72,7 +94,7 @@ module Lita
72
94
  # @param strings [String, Array<String>] One or more strings to send.
73
95
  # @return [void]
74
96
  def send_messages(target, *strings)
75
- @adapter.send_messages(target, strings.flatten)
97
+ adapter.send_messages(target, strings.flatten)
76
98
  end
77
99
  alias_method :send_message, :send_messages
78
100
 
@@ -89,7 +111,7 @@ module Lita
89
111
 
90
112
  mention_name = target.user.mention_name
91
113
  prefixed_strings = strings.map do |s|
92
- "#{@adapter.mention_format(mention_name).strip} #{s}"
114
+ "#{adapter.mention_format(mention_name).strip} #{s}"
93
115
  end
94
116
 
95
117
  send_messages(target, *prefixed_strings)
@@ -101,7 +123,7 @@ module Lita
101
123
  # @param topic [String] The new topic message to set.
102
124
  # @return [void]
103
125
  def set_topic(target, topic)
104
- @adapter.set_topic(target, topic)
126
+ adapter.set_topic(target, topic)
105
127
  end
106
128
 
107
129
  # Gracefully shuts the robot down, stopping the web server and delegating
@@ -112,7 +134,7 @@ module Lita
112
134
  trigger(:shut_down_started)
113
135
  @server.stop(true) if @server
114
136
  @server_thread.join if @server_thread
115
- @adapter.shut_down
137
+ adapter.shut_down
116
138
  trigger(:shut_down_complete)
117
139
  end
118
140
 
@@ -123,33 +145,49 @@ module Lita
123
145
  # @param payload [Hash] An optional hash of arbitrary data.
124
146
  # @return [void]
125
147
  def trigger(event_name, payload = {})
126
- Lita.handlers.each do |handler|
148
+ handlers.each do |handler|
149
+ next unless handler.respond_to?(:trigger)
150
+
127
151
  handler.trigger(self, event_name, payload)
128
152
  end
129
153
  end
130
154
 
131
155
  private
132
156
 
157
+ # Loads and caches the adapter on first access.
158
+ def adapter
159
+ @adapter ||= load_adapter
160
+ end
161
+
133
162
  # Loads the selected adapter.
134
163
  def load_adapter
135
- adapter_name = Lita.config.robot.adapter
136
- adapter_class = Lita.adapters[adapter_name.to_sym]
164
+ adapter_name = config.robot.adapter
165
+ adapter_class = adapters[adapter_name.to_sym]
137
166
 
138
167
  unless adapter_class
139
168
  Lita.logger.fatal I18n.t("lita.robot.unknown_adapter", adapter: adapter_name)
140
169
  abort
141
170
  end
142
171
 
143
- @adapter = adapter_class.new(self)
172
+ adapter_class.new(self)
144
173
  end
145
174
 
146
175
  # Starts the web server.
147
176
  def run_app
148
- http_config = Lita.config.http
177
+ http_config = config.http
149
178
 
150
179
  @server_thread = Thread.new do
151
180
  @server = Puma::Server.new(app)
152
- @server.add_tcp_listener(http_config.host, http_config.port.to_i)
181
+ begin
182
+ @server.add_tcp_listener(http_config.host, http_config.port.to_i)
183
+ rescue Errno::EADDRINUSE, Errno::EACCES => e
184
+ Lita.logger.fatal I18n.t(
185
+ "lita.http.exception",
186
+ message: e.message,
187
+ backtrace: e.backtrace.join("\n")
188
+ )
189
+ abort
190
+ end
153
191
  @server.min_threads = http_config.min_threads
154
192
  @server.max_threads = http_config.max_threads
155
193
  @server.run
@@ -14,6 +14,10 @@ module Lita
14
14
  # The route being checked.
15
15
  attr_reader :route
16
16
 
17
+ # @param handler [Lita::Handler] The handler the route belongs to.
18
+ # @param route [Lita::Handler::ChatRouter::Route] The route being validated.
19
+ # @param message [Lita::Message] The incoming message.
20
+ # @param robot [Lita::Robot] The currently running robot.
17
21
  def initialize(handler, route, message, robot)
18
22
  @handler = handler
19
23
  @route = route
@@ -27,7 +31,7 @@ module Lita
27
31
  return unless command_satisfied?(route, message)
28
32
  return if from_self?(message, robot)
29
33
  return unless matches_pattern?(route, message)
30
- return unless authorized?(message.user, route.required_groups)
34
+ return unless authorized?(robot, message.user, route.required_groups)
31
35
  return unless passes_route_hooks?(route, message, robot)
32
36
 
33
37
  true
@@ -52,15 +56,19 @@ module Lita
52
56
 
53
57
  # Allow custom route hooks to reject the route
54
58
  def passes_route_hooks?(route, message, robot)
55
- Lita.hooks[:validate_route].all? do |hook|
59
+ robot.hooks[:validate_route].all? do |hook|
56
60
  hook.call(handler: handler, route: route, message: message, robot: robot)
57
61
  end
58
62
  end
59
63
 
60
64
  # User must be in auth group if route is restricted.
61
- def authorized?(user, required_groups)
65
+ def authorized?(robot, user, required_groups)
62
66
  required_groups.nil? || required_groups.any? do |group|
63
- Authorization.user_in_group?(user, group)
67
+ if Lita.version_3_compatibility_mode?
68
+ Lita::Authorization.user_in_group?(user, group)
69
+ else
70
+ robot.auth.user_in_group?(user, group)
71
+ end
64
72
  end
65
73
  end
66
74
  end
@@ -9,6 +9,7 @@ end
9
9
  major, *_unused = RSpec::Core::Version::STRING.split(/\./)
10
10
  abort I18n.t("lita.rspec.version_3_required") if major.to_i < 3
11
11
 
12
+ require_relative "../lita"
12
13
  require_relative "rspec/handler"
13
14
 
14
15
  module Lita
@@ -23,26 +24,21 @@ module Lita
23
24
  # @return [void]
24
25
  def included(base)
25
26
  base.class_eval do
26
- before do
27
- logger = double("Logger").as_null_object
28
- allow(Lita).to receive(:logger).and_return(logger)
29
- Lita.clear_config
27
+ let(:registry) do
28
+ if Lita.version_3_compatibility_mode?
29
+ Lita
30
+ else
31
+ Registry.new
32
+ end
30
33
  end
31
- end
32
34
 
33
- prepare_redis(base)
34
- end
35
-
36
- private
37
-
38
- # Set up Redis to use the test namespace and clear out before each
39
- # example.
40
- def prepare_redis(base)
41
- base.class_eval do
42
35
  before do
36
+ logger = double("Logger").as_null_object
37
+ allow(Lita).to receive(:logger).and_return(logger)
43
38
  stub_const("Lita::REDIS_NAMESPACE", "lita.test")
44
39
  keys = Lita.redis.keys("*")
45
40
  Lita.redis.del(keys) unless keys.empty?
41
+ registry.clear_config if Lita.version_3_compatibility_mode?
46
42
  end
47
43
  end
48
44
  end
@@ -50,7 +46,20 @@ module Lita
50
46
  end
51
47
  end
52
48
 
49
+ Lita.test_mode = true
50
+ Lita.version_3_compatibility_mode = true
51
+
53
52
  RSpec.configure do |config|
54
53
  config.include Lita::RSpec, lita: true
55
54
  config.include Lita::RSpec::Handler, lita_handler: true
55
+
56
+ config.before(:suite) do
57
+ if Lita.version_3_compatibility_mode?
58
+ if RSpec.configuration.color_enabled?
59
+ warn "\e[31m" + I18n.t("lita.rspec.lita_3_compatibility_mode") + "\e[0m"
60
+ else
61
+ warn I18n.t("lita.rspec.lita_3_compatibility_mode")
62
+ end
63
+ end
64
+ end
56
65
  end
@@ -1,17 +1,20 @@
1
- require_relative "matchers/route_matcher"
1
+ require_relative "matchers/chat_route_matcher"
2
2
  require_relative "matchers/http_route_matcher"
3
- require_relative "matchers/event_subscription_matcher"
3
+ require_relative "matchers/event_route_matcher"
4
+ require_relative "matchers/deprecated"
4
5
 
5
6
  module Lita
6
7
  module RSpec
7
8
  # Extras for +RSpec+ to facilitate testing Lita handlers.
8
9
  module Handler
10
+ include Matchers::ChatRouteMatcher
11
+ include Matchers::HTTPRouteMatcher
12
+ include Matchers::EventRouteMatcher
13
+
9
14
  class << self
10
15
  # Sets up the RSpec environment to easily test Lita handlers.
11
16
  def included(base)
12
- base.class_eval do
13
- include Lita::RSpec
14
- end
17
+ base.send(:include, Lita::RSpec)
15
18
 
16
19
  prepare_handlers(base)
17
20
  prepare_let_blocks(base)
@@ -24,14 +27,20 @@ module Lita
24
27
  # Stub Lita.handlers.
25
28
  def prepare_handlers(base)
26
29
  base.class_eval do
27
- before { allow(Lita).to receive(:handlers).and_return([described_class]) }
30
+ before do
31
+ if Lita.version_3_compatibility_mode?
32
+ allow(Lita).to receive(:handlers).and_return(Set.new([described_class]))
33
+ else
34
+ registry.register_handler(described_class)
35
+ end
36
+ end
28
37
  end
29
38
  end
30
39
 
31
40
  # Create common test objects.
32
41
  def prepare_let_blocks(base)
33
42
  base.class_eval do
34
- let(:robot) { Robot.new }
43
+ let(:robot) { Robot.new(registry) }
35
44
  let(:source) { Source.new(user: user) }
36
45
  let(:user) { User.create("1", name: "Test User") }
37
46
  let(:replies) { [] }
@@ -82,41 +91,78 @@ module Lita
82
91
  send_message("#{robot.mention_name}: #{body}", as: as)
83
92
  end
84
93
 
94
+ # Returns a Faraday connection hooked up to the currently running robot's Rack app.
95
+ # @return [Faraday::Connection] The connection.
96
+ # @since 4.0.0
97
+ def http
98
+ begin
99
+ require "rack/test"
100
+ rescue LoadError
101
+ raise LoadError, I18n.t("lita.rspec.rack_test_required")
102
+ end unless Rack.const_defined?(:Test)
103
+
104
+ Faraday::Connection.new { |c| c.adapter(:rack, robot.app) }
105
+ end
106
+
85
107
  # Starts a chat routing test chain, asserting that a message should
86
108
  # trigger a route.
87
109
  # @param message [String] The message that should trigger the route.
88
- # @return [Matchers::RouteMatcher] A {Matchers::RouteMatcher} that should have +to+
110
+ # @return [Matchers::Deprecated] A {Matchers::Deprecated} that should have +to+
89
111
  # called on it to complete the test.
112
+ # @deprecated Will be removed in Lita 5.0. Use +is_expected.to route+ instead.
90
113
  def routes(message)
91
- Matchers::RouteMatcher.new(self, message)
114
+ STDERR.puts I18n.t(
115
+ "lita.rspec.matcher_deprecated",
116
+ old_method: "routes",
117
+ new_method: "is_expected.to route",
118
+ )
119
+ Matchers::Deprecated.new(self, :route, true, message)
92
120
  end
93
121
 
94
122
  # Starts a chat routing test chain, asserting that a message should not
95
123
  # trigger a route.
96
124
  # @param message [String] The message that should not trigger the route.
97
- # @return [Matchers::RouteMatcher] A {Matchers::RouteMatcher} that should have +to+
125
+ # @return [Matchers::Deprecated] A {Matchers::Deprecated} that should have +to+
98
126
  # called on it to complete the test.
127
+ # @deprecated Will be removed in Lita 5.0. Use +is_expected.not_to route+ instead.
99
128
  def does_not_route(message)
100
- Matchers::RouteMatcher.new(self, message, expectation: false)
129
+ STDERR.puts I18n.t(
130
+ "lita.rspec.matcher_deprecated",
131
+ old_method: "does_not_route",
132
+ new_method: "is_expected.not_to route",
133
+ )
134
+ Matchers::Deprecated.new(self, :route, false, message)
101
135
  end
102
136
  alias_method :doesnt_route, :does_not_route
103
137
 
104
138
  # Starts a chat routing test chain, asserting that a "command" message
105
139
  # should trigger a route.
106
140
  # @param message [String] The message that should trigger the route.
107
- # @return [Matchers::RouteMatcher] A {Matchers::RouteMatcher} that should have +to+
141
+ # @return [Matchers::Deprecated] A {Matchers::Deprecated} that should have +to+
108
142
  # called on it to complete the test.
143
+ # @deprecated Will be removed in Lita 5.0. Use +is_expected.to route_command+ instead.
109
144
  def routes_command(message)
110
- Matchers::RouteMatcher.new(self, "#{robot.mention_name}: #{message}")
145
+ STDERR.puts I18n.t(
146
+ "lita.rspec.matcher_deprecated",
147
+ old_method: "routes_command",
148
+ new_method: "is_expected.to route_command",
149
+ )
150
+ Matchers::Deprecated.new(self, :route_command, true, message)
111
151
  end
112
152
 
113
153
  # Starts a chat routing test chain, asserting that a "command" message
114
154
  # should not trigger a route.
115
155
  # @param message [String] The message that should not trigger the route.
116
- # @return [Matchers::RouteMatcher] A {Matchers::RouteMatcher} that should have +to+
156
+ # @return [Matchers::Deprecated] A {Matchers::Deprecated} that should have +to+
117
157
  # called on it to complete the test.
158
+ # @deprecated Will be removed in Lita 5.0. Use +is_expected.not_to route_command+ instead.
118
159
  def does_not_route_command(message)
119
- Matchers::RouteMatcher.new(self, "#{robot.mention_name}: #{message}", expectation: false)
160
+ STDERR.puts I18n.t(
161
+ "lita.rspec.matcher_deprecated",
162
+ old_method: "does_not_route_command",
163
+ new_method: "is_expected.not_to route_command",
164
+ )
165
+ Matchers::Deprecated.new(self, :route_command, false, message)
120
166
  end
121
167
  alias_method :doesnt_route_command, :does_not_route_command
122
168
 
@@ -126,10 +172,16 @@ module Lita
126
172
  # the route.
127
173
  # @param path [String] The path URL component that should trigger the
128
174
  # route.
129
- # @return [Matchers::HTTPRouteMatcher] A {Matchers::HTTPRouteMatcher} that should
175
+ # @return [Matchers::Deprecated] A {Matchers::Deprecated} that should
130
176
  # have +to+ called on it to complete the test.
177
+ # @deprecated Will be removed in Lita 5.0. Use +is_expected.to route_http+ instead.
131
178
  def routes_http(http_method, path)
132
- Matchers::HTTPRouteMatcher.new(self, http_method, path)
179
+ STDERR.puts I18n.t(
180
+ "lita.rspec.matcher_deprecated",
181
+ old_method: "routes_http",
182
+ new_method: "is_expected.to route_http",
183
+ )
184
+ Matchers::Deprecated.new(self, :route_http, true, http_method, path)
133
185
  end
134
186
 
135
187
  # Starts an HTTP routing test chain, asserting that a request to the given
@@ -138,10 +190,16 @@ module Lita
138
190
  # trigger the route.
139
191
  # @param path [String] The path URL component that should not trigger the
140
192
  # route.
141
- # @return [Matchers::HTTPRouteMatcher] A {Matchers::HTTPRouteMatcher} that should
193
+ # @return [Matchers::Deprecated] A {Matchers::Deprecated} that should
142
194
  # have +to+ called on it to complete the test.
195
+ # @deprecated Will be removed in Lita 5.0. Use +is_expected.not_to route_http+ instead.
143
196
  def does_not_route_http(http_method, path)
144
- Matchers::HTTPRouteMatcher.new(self, http_method, path, expectation: false)
197
+ STDERR.puts I18n.t(
198
+ "lita.rspec.matcher_deprecated",
199
+ old_method: "does_not_route_http",
200
+ new_method: "is_expected.not_to route_http",
201
+ )
202
+ Matchers::Deprecated.new(self, :route_http, false, http_method, path)
145
203
  end
146
204
  alias_method :doesnt_route_http, :does_not_route_http
147
205
 
@@ -149,20 +207,32 @@ module Lita
149
207
  # trigger the target method.
150
208
  # @param event_name [String, Symbol] The name of the event that should
151
209
  # be triggered.
152
- # @return [Matchers::EventSubscriptionMatcher] A {Matchers::EventSubscriptionMatcher} that
210
+ # @return [Matchers::Deprecated] A {Matchers::Deprecated} that
153
211
  # should have +to+ called on it to complete the test.
212
+ # @deprecated Will be removed in Lita 5.0. Use +is_expected.to route_event+ instead.
154
213
  def routes_event(event_name)
155
- Matchers::EventSubscriptionMatcher.new(self, event_name)
214
+ STDERR.puts I18n.t(
215
+ "lita.rspec.matcher_deprecated",
216
+ old_method: "routes_event",
217
+ new_method: "is_expected.to route_event",
218
+ )
219
+ Matchers::Deprecated.new(self, :route_event, true, event_name)
156
220
  end
157
221
 
158
222
  # Starts an event subscription test chain, asserting that an event should
159
223
  # not trigger the target method.
160
224
  # @param event_name [String, Symbol] The name of the event that should
161
225
  # not be triggered.
162
- # @return [Matchers::EventSubscriptionMatcher] A {Matchers::EventSubscriptionMatcher} that
226
+ # @return [Matchers::Deprecated] A {Matchers::Deprecated} that
163
227
  # should have +to+ called on it to complete the test.
228
+ # @deprecated Will be removed in Lita 5.0. Use +is_expected.not_to route_event+ instead.
164
229
  def does_not_route_event(event_name)
165
- Matchers::EventSubscriptionMatcher.new(self, event_name, expectation: false)
230
+ STDERR.puts I18n.t(
231
+ "lita.rspec.matcher_deprecated",
232
+ old_method: "does_not_route_event",
233
+ new_method: "is_expected.not_to route_event",
234
+ )
235
+ Matchers::Deprecated.new(self, :route_event, false, event_name)
166
236
  end
167
237
  alias_method :doesnt_route_event, :does_not_route_event
168
238
  end