Class: TestProf::RSpecStamp::RSpecListener

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/test_prof/rspec_stamp/rspec.rb

Overview

:nodoc:

Constant Summary collapse

NOTIFICATIONS =
i[
  example_failed
].freeze

Constants included from Logging

Logging::COLORS

Instance Method Summary collapse

Methods included from Logging

#build_log_msg, #colorize, #log

Constructor Details

#initializeRSpecListener

Returns a new instance of RSpecListener.



15
16
17
18
19
20
# File 'lib/test_prof/rspec_stamp/rspec.rb', line 15

def initialize
  @failed = 0
  @ignored = 0
  @total = 0
  @examples = Hash.new { |h, k| h[k] = [] }
end

Instance Method Details

#example_failed(notification) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/test_prof/rspec_stamp/rspec.rb', line 22

def example_failed(notification)
  return if notification.example.pending?

  location = notification.example.[:location]

  file, line = location.split(":")

  @examples[file] << line.to_i
end

#stamp!Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/test_prof/rspec_stamp/rspec.rb', line 32

def stamp!
  @examples.each do |file, lines|
    stamp_file(file, lines.uniq)
  end

  msgs = []

  msgs <<
    "      RSpec Stamp results\n\n      Total patches: \#{@total}\n      Total files: \#{@examples.keys.size}\n\n      Failed patches: \#{@failed}\n      Ignored files: \#{@ignored}\n    MSG\n\n  log :info, msgs.join\nend\n".strip_heredoc