Class: RSpec::Conductor::RSpecSubscriber
- Inherits:
-
Object
- Object
- RSpec::Conductor::RSpecSubscriber
- Defined in:
- lib/rspec/conductor/rspec_subscriber.rb
Overview
Technically this is a Formatter, as in RSpec Formatter, but that was too confusing, and there is another thing called formatter in this library. Hence, Subscriber.
Instance Method Summary collapse
- #example_failed(notification) ⇒ Object
- #example_passed(notification) ⇒ Object
- #example_pending(notification) ⇒ Object
-
#initialize(socket, file, shutdown_check) ⇒ RSpecSubscriber
constructor
A new instance of RSpecSubscriber.
-
#retry(ex) ⇒ Object
This one is invoked by rspec-retry, hence the slightly different api from example_* methods.
Constructor Details
#initialize(socket, file, shutdown_check) ⇒ RSpecSubscriber
13 14 15 16 17 |
# File 'lib/rspec/conductor/rspec_subscriber.rb', line 13 def initialize(socket, file, shutdown_check) @socket = socket @file = file @shutdown_check = shutdown_check end |
Instance Method Details
#example_failed(notification) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rspec/conductor/rspec_subscriber.rb', line 32 def example_failed(notification) ex = notification.example @socket.( type: :example_failed, id: ex.id, file: @file, description: ex.full_description, location: ex.location, run_time: ex.execution_result.run_time, exception_class: ex.execution_result.exception&.class&.name, message: ex.execution_result.exception&., backtrace: format_backtrace(ex.execution_result.exception&.backtrace, ex.) ) @shutdown_check.call end |
#example_passed(notification) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rspec/conductor/rspec_subscriber.rb', line 19 def example_passed(notification) ex = notification.example @socket.( type: :example_passed, id: ex.id, file: @file, description: ex.full_description, location: ex.location, run_time: ex.execution_result.run_time ) @shutdown_check.call end |
#example_pending(notification) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rspec/conductor/rspec_subscriber.rb', line 48 def example_pending(notification) ex = notification.example @socket.( type: :example_pending, id: ex.id, file: @file, description: ex.full_description, location: ex.location, pending_message: ex.execution_result. ) @shutdown_check.call end |
#retry(ex) ⇒ Object
This one is invoked by rspec-retry, hence the slightly different api from example_* methods
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rspec/conductor/rspec_subscriber.rb', line 62 def retry(ex) @socket.( type: :example_retried, description: ex.full_description, location: ex.location, exception_class: ex.exception&.class&.name, message: ex.exception&., backtrace: format_backtrace(ex.exception&.backtrace, ex.) ) end |