Class: FlakeySpecCatcher::EventListener

Inherits:
Object
  • Object
show all
Defined in:
lib/flakey_spec_catcher/event_listener.rb

Overview

EventListener class

Listens for events from RSpec and processes data from those events.

This event listener will receive example_failed and example_passed events from RSpec and will log those results into the provided result manager

Instance Method Summary collapse

Constructor Details

#initialize(result_manager) ⇒ EventListener

Returns a new instance of EventListener.



13
14
15
# File 'lib/flakey_spec_catcher/event_listener.rb', line 13

def initialize(result_manager)
  @result_manager = result_manager
end

Instance Method Details

#example_failed(notification) ⇒ Object



17
18
19
20
21
# File 'lib/flakey_spec_catcher/event_listener.rb', line 17

def example_failed(notification)
  description = notification.example.full_description.to_s.strip
  location = notification.example.location
  @result_manager.add_result(description, location, format_message(notification))
end

#example_passed(notification) ⇒ Object



23
24
25
26
27
# File 'lib/flakey_spec_catcher/event_listener.rb', line 23

def example_passed(notification)
  description = notification.example.full_description.to_s.strip
  location = notification.example.location
  @result_manager.add_result(description, location)
end