class Detroit::MiniTest

The MiniTest tool runs tests. For Ruby 1.9+ ‘minitest/autorun` is used to run the tests. For older versions of Ruby, `test/unit` is used.

Constants

DEFAULT_TESTS

By default look for tests in test directory.

Attributes

exclude[R]

Test files or globs to ignore.

extra[RW]
ignore[R]

Test files to ignore by matching filename.

loadpath[R]
requires[R]
tests[R]

Test files to include.

Public Class Methods

man_page() click to toggle source
# File lib/detroit-minitest.rb, line 132
def self.man_page
  File.dirname(__FILE__)+'/../man/detroit-minitest.5'      
end

Public Instance Methods

assemble(station, options={}) click to toggle source
# File lib/detroit-minitest.rb, line 74
def assemble(station, options={})
  case station
  when :test then test
  end
end
assemble?(station, options={}) click to toggle source
# File lib/detroit-minitest.rb, line 67
def assemble?(station, options={})
  case station
  when :test then true
  end
end
exclude=(paths) click to toggle source
# File lib/detroit-minitest.rb, line 32
def exclude=(paths)
  @exclude = [paths].flatten
end
ignore=(paths) click to toggle source
# File lib/detroit-minitest.rb, line 40
def ignore=(paths)
  @ignore = [paths].flatten
end
loadpath=(paths) click to toggle source
# File lib/detroit-minitest.rb, line 48
def loadpath=(paths)
  @loadpath = [paths].flatten
end
requires=(paths) click to toggle source
# File lib/detroit-minitest.rb, line 56
def requires=(paths)
  @requires = [paths].flatten
end
test() click to toggle source

Run tests.

# File lib/detroit-minitest.rb, line 84
def test
  requires = [autorunner] + self.requires

  cmd = []
  loadpath.each do |path|
    cmd << "-I#{path}"
  end     
  requires.each do |path|
    cmd << "-r#{path}"
  end
  cmd << "-e '%w{" + resolved_tests.join(' ') + "}.each{ |f| require f }'"
  cmd << extra.to_s if extra

  success = ruby(cmd.join(' '))

  abort "Aborted due to test failures. Use --force to override." unless success or force?
end
tests=(paths) click to toggle source
# File lib/detroit-minitest.rb, line 24
def tests=(paths)
  @tests = [paths].flatten
end

Private Instance Methods

autorunner() click to toggle source
# File lib/detroit-minitest.rb, line 122
def autorunner
  if RUBY_VERSION < '1.9'
    'test/unit'
  else
    'minitest/autorun'
  end
end
initialize_defaults() click to toggle source
# File lib/detroit-minitest.rb, line 105
def initialize_defaults
  @tests    = DEFAULT_TESTS
  @exclude  = []
  @ignore   = []
  @loadpath = []
  @requires = []
end
resolved_tests() click to toggle source

Resolve test globs.

# File lib/detroit-minitest.rb, line 114
def resolved_tests
  @resolved_tests ||= (
    list = amass(tests, exclude, ignore)
    list.map{ |f| "./#{f}" }
  )
end