Class: TestProf::RubyProf::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/test_prof/ruby_prof/rspec.rb

Overview

Reporter for RSpec to profile specific examples with RubyProf

Constant Summary collapse

NOTIFICATIONS =
%i[
  example_started
  example_finished
].freeze

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.report_name_generatorObject

Returns the value of attribute report_name_generator.



12
13
14
# File 'lib/test_prof/ruby_prof/rspec.rb', line 12

def report_name_generator
  @report_name_generator
end

Instance Method Details

#example_finished(notification) ⇒ Object



28
29
30
31
32
33
# File 'lib/test_prof/ruby_prof/rspec.rb', line 28

def example_finished(notification)
  return unless profile?(notification.example)
  notification.example.[:rprof_report]&.dump(
    self.class.report_name_generator.call(notification.example)
  )
end

#example_started(notification) ⇒ Object



22
23
24
25
26
# File 'lib/test_prof/ruby_prof/rspec.rb', line 22

def example_started(notification)
  return unless profile?(notification.example)
  notification.example.[:rprof_report] =
    TestProf::RubyProf.profile
end