class Heckle::Reporter

Public Instance Methods

diff(original, mutation) click to toggle source
# File lib/heckle.rb, line 811
def diff(original, mutation)
  length = [original.split(%r\n/).size, mutation.split(%r\n/).size].max

  Tempfile.open("orig") do |a|
    a.puts(original)
    a.flush

    Tempfile.open("fail") do |b|
      b.puts(mutation)
      b.flush

      diff_flags = " "

      output = %x#{Heckle::DIFF} -U #{length} --label original #{a.path} --label mutation #{b.path}`
      puts output.sub(%r^@@.*?\n/, '')
      puts
    end
  end
end
failure(original, failure) click to toggle source
# File lib/heckle.rb, line 831
def failure(original, failure)
  self.diff original, failure
end
info(message) click to toggle source
# File lib/heckle.rb, line 798
def info(message)
  puts "*"*70
  puts "***  #{message}"
  puts "*"*70
  puts
end
method_loaded(klass_name, method_name, mutations_left) click to toggle source
# File lib/heckle.rb, line 783
def method_loaded(klass_name, method_name, mutations_left)
  info "#{klass_name}\##{method_name} loaded with #{mutations_left} possible mutations"
end
no_failures() click to toggle source
# File lib/heckle.rb, line 805
def no_failures
  puts
  puts "The following mutations didn't cause test failures:"
  puts
end
no_mutations(method_name) click to toggle source
# File lib/heckle.rb, line 779
def no_mutations(method_name)
  warning "#{method_name} has a thick skin. There's nothing to heckle."
end
no_surviving_mutants() click to toggle source
# File lib/heckle.rb, line 835
def no_surviving_mutants
  puts "No mutants survived. Cool!\n\n"
end
remaining_mutations(mutations_left) click to toggle source
# File lib/heckle.rb, line 787
def remaining_mutations(mutations_left)
  puts "#{mutations_left} mutations remaining..."
end
replacing(klass_name, method_name, original, src) click to toggle source
# File lib/heckle.rb, line 839
def replacing(klass_name, method_name, original, src)
  puts "Replacing #{klass_name}##{method_name} with:\n\n"
  diff(original, src)
end
report_test_failures() click to toggle source
# File lib/heckle.rb, line 844
def report_test_failures
  puts "Tests failed -- this is good" if Heckle.debug
end
warning(message) click to toggle source
# File lib/heckle.rb, line 791
def warning(message)
  puts "!" * 70
  puts "!!! #{message}"
  puts "!" * 70
  puts
end