module Tunit

Constants

VERSION

Public Class Methods

autorun() click to toggle source
# File lib/tunit.rb, line 21
def self.autorun
  at_exit {
    next if $! and not ($!.kind_of? SystemExit and $!.success?)

    exit_code = nil

    at_exit {
      exit exit_code || false
    }

    exit_code = Tunit.run ARGV
  } unless self.installed_at_exit
  self.installed_at_exit = true
end
run(args = []) click to toggle source
# File lib/tunit.rb, line 36
def self.run args = []
  options = process_args! args

  self.reporter = CompoundReporter.new
  reporter << SummaryReporter.new(options[:io], options)
  reporter << ProgressReporter.new(options[:io], options)

  reporter.start
  dispatch! reporter, options
  reporter.report

  reporter.passed?
end

Private Class Methods

dispatch!(reporter, options) click to toggle source
# File lib/tunit.rb, line 52
def self.dispatch! reporter, options
  Runnable.runnables.each do |runnable|
    runnable.run reporter, options
  end
end
process_args!(args = []) click to toggle source
# File lib/tunit.rb, line 58
def self.process_args! args = []
  options = { io: io }

  OptionParser.new do |opts|
    opts.banner  = "Tunit options:"
    opts.version = Tunit::VERSION

    opts.on "-h", "--help", "Display this help." do
      puts opts
      exit
    end

    opts.on "-n", "--name PATTERN", "Filter run on /pattern/ or string." do |pattern|
      options[:filter] = pattern
    end

    opts.on "-v", "--verbose", "Verbose. Show progress processing files." do
      options[:verbose] = true
    end

    opts.parse! args
  end

  options
end