@@ -17,6 +17,9 @@ def setup
1717 @original_stdout = $stdout
1818 @stdout_buffer = StringIO . new
1919 $stdout = @stdout_buffer
20+
21+ # Define mock constants for error reporting services if they don't exist
22+ setup_mock_constants
2023 end
2124
2225 def teardown
@@ -206,5 +209,82 @@ def test_report_error_with_no_service
206209 end
207210 end
208211 end
212+
213+ private
214+
215+ def setup_mock_constants
216+ # Define mock constants for error reporting services if they don't exist
217+ unless defined? ( ::Sentry )
218+ sentry_class = Class . new do
219+ def self . capture_exception ( *args )
220+ # Mock implementation
221+ end
222+
223+ def self . stub ( method , &block )
224+ # Mock stub method for minitest
225+ original_method = singleton_method ( method )
226+ define_singleton_method ( method , &block )
227+ yield
228+ ensure
229+ define_singleton_method ( method , original_method . to_proc ) if original_method
230+ end
231+ end
232+ Object . const_set ( :Sentry , sentry_class )
233+ end
234+
235+ unless defined? ( ::Bugsnag )
236+ bugsnag_class = Class . new do
237+ def self . notify ( *args )
238+ # Mock implementation
239+ end
240+
241+ def self . stub ( method , &block )
242+ # Mock stub method for minitest
243+ original_method = singleton_method ( method )
244+ define_singleton_method ( method , &block )
245+ yield
246+ ensure
247+ define_singleton_method ( method , original_method . to_proc ) if original_method
248+ end
249+ end
250+ Object . const_set ( :Bugsnag , bugsnag_class )
251+ end
252+
253+ unless defined? ( ::Rollbar )
254+ rollbar_class = Class . new do
255+ def self . error ( *args )
256+ # Mock implementation
257+ end
258+
259+ def self . stub ( method , &block )
260+ # Mock stub method for minitest
261+ original_method = singleton_method ( method )
262+ define_singleton_method ( method , &block )
263+ yield
264+ ensure
265+ define_singleton_method ( method , original_method . to_proc ) if original_method
266+ end
267+ end
268+ Object . const_set ( :Rollbar , rollbar_class )
269+ end
270+
271+ unless defined? ( ::Honeybadger )
272+ honeybadger_class = Class . new do
273+ def self . notify ( *args )
274+ # Mock implementation
275+ end
276+
277+ def self . stub ( method , &block )
278+ # Mock stub method for minitest
279+ original_method = singleton_method ( method )
280+ define_singleton_method ( method , &block )
281+ yield
282+ ensure
283+ define_singleton_method ( method , original_method . to_proc ) if original_method
284+ end
285+ end
286+ Object . const_set ( :Honeybadger , honeybadger_class )
287+ end
288+ end
209289 end
210290end
0 commit comments