class TestProf::RSpecStamp::Stamper

Stamper collects statistics about applying tags to examples.

Attributes

failed[R]
ignored[R]
total[R]

Public Class Methods

new() click to toggle source
# File lib/test_prof/rspec_stamp.rb, line 55
def initialize
  @total = 0
  @failed = 0
  @ignored = 0
end

Public Instance Methods

stamp_file(file, lines) click to toggle source
# 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

Private Instance Methods

dry_run?() click to toggle source
# File lib/test_prof/rspec_stamp.rb, line 86
def dry_run?
  RSpecStamp.config.dry_run?
end
ignored?(file) click to toggle source
# File lib/test_prof/rspec_stamp.rb, line 76
def ignored?(file)
  ignored = RSpecStamp.config.ignore_files.find do |pattern|
    file =~ pattern
  end

  return unless ignored
  log :warn, "Ignore stamping file: #{file}"
  @ignored += 1
end