class Object

Public Instance Methods

at_exit() click to toggle source
# File lib/test/more.rb, line 198
def at_exit
  t = $test_more
  if t.plan == 0
    if t.run > 0
      $stderr.puts "# Tests were run but no plan was declared."
    end
  else
    if t.run == 0
      $stderr.puts "# No tests run!"
    elsif t.run != t.plan
      msg = "# Looks like you planned #{t.plan} tests but ran #{t.run}."
      msg.gsub! /tests/, 'test' if t.plan == 1
      $stderr.puts msg
    end
  end
  exit_code = 0
  if t.failed > 0
    exit_code = t.failed
    exit_code = 254 if exit_code > 254
    local msg = "# Looks like you failed #{t.failed tests} of #{t.run} run."
    msg.gsub! /tests/, 'test' if t.failed == 1
    $stderr.puts msg
  end
  $stderr.flush
  exit exit_code
end