class Suspect::Gathering::RSpec::Listener
Depends on:
-
RSpec::Core::Reporter#examples
-
RSpec::Core::Reporter#failed_examples
-
RSpec::Core::Reporter#pending_examples
-
RSpec::Core::Example#file_path
Attributes
clock[R]
collector_id[R]
file_tree[R]
storage_appender[R]
Public Class Methods
new(file_tree, storage_appender, collector_id, clock)
click to toggle source
# File lib/suspect/gathering/rspec/listener.rb, line 14 def initialize(file_tree, storage_appender, collector_id, clock) @file_tree = file_tree @storage_appender = storage_appender @collector_id = collector_id @clock = clock end
Public Instance Methods
notification_names()
click to toggle source
# File lib/suspect/gathering/rspec/listener.rb, line 21 def notification_names %i(stop) end
stop(notification)
click to toggle source
# File lib/suspect/gathering/rspec/listener.rb, line 25 def stop(notification) run_info = build_run_info(notification) if run_info.failed_files.any? storage_appender.append run_info end end
Private Instance Methods
build_run_info(notification)
click to toggle source
# File lib/suspect/gathering/rspec/listener.rb, line 37 def build_run_info(notification) ::Suspect::Gathering::RunInfo.new.tap do |info| info.collector_id = collector_id info.notified_at = clock.iso8601 info.failed_example_count = failed_example_count(notification) info.pending_example_count = pending_example_count(notification) info.successful_example_count = successful_example_count(notification) info.failed_files = failed_files(notification) info.branch = file_tree.branch info.commit_hash = file_tree.commit_hash info.modified_files = file_tree.modified_files info.patch = file_tree.patch end end
failed_example_count(notification)
click to toggle source
# File lib/suspect/gathering/rspec/listener.rb, line 56 def failed_example_count(notification) notification.failed_examples.size end
failed_files(notification)
click to toggle source
# File lib/suspect/gathering/rspec/listener.rb, line 52 def failed_files(notification) notification.failed_examples.map(&:file_path).sort.uniq end
pending_example_count(notification)
click to toggle source
# File lib/suspect/gathering/rspec/listener.rb, line 60 def pending_example_count(notification) notification.pending_examples.size end
successful_example_count(notification)
click to toggle source
# File lib/suspect/gathering/rspec/listener.rb, line 64 def successful_example_count(notification) notification.examples.size - (failed_example_count(notification) + pending_example_count(notification)) end