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
Returns a new instance of 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
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rspec/conductor/rspec_subscriber.rb', line 30 def example_failed(notification) ex = notification.example @socket.( type: :example_failed, 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 |
# File 'lib/rspec/conductor/rspec_subscriber.rb', line 19 def example_passed(notification) @socket.( type: :example_passed, file: @file, description: notification.example.full_description, location: notification.example.location, run_time: notification.example.execution_result.run_time ) @shutdown_check.call end |
#example_pending(notification) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rspec/conductor/rspec_subscriber.rb', line 45 def example_pending(notification) ex = notification.example @socket.( type: :example_pending, 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
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rspec/conductor/rspec_subscriber.rb', line 58 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 |