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
# File 'lib/test_prof/memory_prof/rspec.rb', line 15

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

  @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



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

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

#example_group_finished(notification) ⇒ Object



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

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

#example_group_started(notification) ⇒ Object



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

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

#example_started(notification) ⇒ Object



22
23
24
# File 'lib/test_prof/memory_prof/rspec.rb', line 22

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

#reportObject



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

def report
  tracker.finish
  printer.print
end