File: thread_error_handling_tests.rb

package info (click to toggle)
ruby-metriks 0.9.9.8-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 288 kB
  • sloc: ruby: 1,877; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 512 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module ThreadErrorHandlingTests
  def test_passes_errors_in_thread_loop_to_on_error_handler
    rescued_error = nil
    error_handler_called = false
    reporter = build_reporter(:interval => 0.0001, :on_error => lambda { |e|
      error_handler_called = true
      rescued_error = e
    })

    reporter.stubs(:write).raises(StandardError, "boom")

    reporter.start
    sleep 0.5
    assert_equal true, error_handler_called
    assert_equal "boom", rescued_error.message
  ensure
    reporter.stop
  end
end