Class: TestProf::MemoryProf::RSpecListener

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

Constant Summary collapse

NOTIFICATIONS =
%i[
  example_started
  example_finished
  example_group_started
  example_group_finished
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRSpecListener

Returns a new instance of RSpecListener.



15
16
17
18
19
20
21
22
23
# File 'lib/test_prof/memory_prof/rspec.rb', line 15

def initialize
  @tracker = MemoryProf.tracker
  @printer = MemoryProf.printer(tracker)

  @current_group = nil
  @current_example = nil

  @tracker.start
end

Instance Attribute Details

#printerObject (readonly)

Returns the value of attribute printer.



13
14
15
# File 'lib/test_prof/memory_prof/rspec.rb', line 13

def printer
  @printer
end

#trackerObject (readonly)

Returns the value of attribute tracker.



13
14
15
# File 'lib/test_prof/memory_prof/rspec.rb', line 13

def tracker
  @tracker
end

Instance Method Details

#example_finished(notification) ⇒ Object



29
30
31
# File 'lib/test_prof/memory_prof/rspec.rb', line 29

def example_finished(notification)
  tracker.example_finished(notification.example)
end

#example_group_finished(notification) ⇒ Object



37
38
39
# File 'lib/test_prof/memory_prof/rspec.rb', line 37

def example_group_finished(notification)
  tracker.group_finished(notification.group)
end

#example_group_started(notification) ⇒ Object



33
34
35
# File 'lib/test_prof/memory_prof/rspec.rb', line 33

def example_group_started(notification)
  tracker.group_started(notification.group, group(notification))
end

#example_started(notification) ⇒ Object



25
26
27
# File 'lib/test_prof/memory_prof/rspec.rb', line 25

def example_started(notification)
  tracker.example_started(notification.example, example(notification))
end

#reportObject



41
42
43
44
# File 'lib/test_prof/memory_prof/rspec.rb', line 41

def report
  tracker.finish
  printer.print
end