Class: TestProf::RSpecStamp::Stamper

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

Overview

Stamper collects statistics about applying tags to examples.

Constant Summary

Constants included from Logging

Logging::COLORS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#log

Constructor Details

#initializeStamper

Returns a new instance of Stamper.



55
56
57
58
59
# File 'lib/test_prof/rspec_stamp.rb', line 55

def initialize
  @total = 0
  @failed = 0
  @ignored = 0
end

Instance Attribute Details

#failedObject (readonly)

Returns the value of attribute failed.



53
54
55
# File 'lib/test_prof/rspec_stamp.rb', line 53

def failed
  @failed
end

#ignoredObject (readonly)

Returns the value of attribute ignored.



53
54
55
# File 'lib/test_prof/rspec_stamp.rb', line 53

def ignored
  @ignored
end

#totalObject (readonly)

Returns the value of attribute total.



53
54
55
# File 'lib/test_prof/rspec_stamp.rb', line 53

def total
  @total
end

Instance Method Details

#stamp_file(file, lines) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/test_prof/rspec_stamp.rb', line 61

def stamp_file(file, lines)
  @total += lines.size
  return if ignored?(file)

  log :info, "(dry-run) Patching #{file}" if dry_run?

  code = File.readlines(file)

  @failed += RSpecStamp.apply_tags(code, lines, RSpecStamp.config.tags)

  File.write(file, code.join) unless dry_run?
end