Method: Protest::Report.on
- Defined in:
- lib/protest/report.rb
.on(event, &block) ⇒ Object
Define an event handler for your report. The different events fired in a report’s life cycle are:
- :start
-
Fired by the runner when starting the whole test suite.
- :enter
-
Fired by the runner when starting a particular test case. It will get the test case as an argument.
- :test
-
Fired by a test before it starts running. It will get the instance of TestCase for the given test as an argument.
- :assertion
-
Fired by a test each time an assertion is run.
- :pass
-
Fired by a test after it runs successfully without errors. It will get an instance of PassedTest as an argument.
- :pending
-
Fired by a test which doesn’t provide a test block or which calls TestCase#pending. It will get an instance of PendingTest as an argument.
- :failure
-
Fired by a test in which an assertion failed. It will get an instance of FailedTest as an argument.
- :error
-
Fired by a test where an uncaught exception was found. It will get an instance of ErroredTest as an argument.
- :exit
-
Fired by the runner each time a test case finishes. It will take the test case as an argument.
- :end
-
Fired by the runner at the end of the whole test suite.
The event handler will receive the report as a first argument, plus any arguments documented above (depending on the event). It will also ensure that any handler for the same event declared on an ancestor class is run.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/protest/report.rb', line 28 def self.on(event, &block) define_method(:"on_#{event}") do |*args| begin super(*args) rescue NoMethodError end block.call(self, *args) end end |