Class: Detroit::MiniTest

Inherits:
Tool
  • Object
show all
Defined in:
lib/detroit-minitest.rb

Overview

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.

Constant Summary collapse

DEFAULT_TESTS =

By default look for tests in test directory.

['test/*_test.rb', 'test/test_*.rb']

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#excludeObject

Test files or globs to ignore.



29
30
31
# File 'lib/detroit-minitest.rb', line 29

def exclude
  @exclude
end

#extraObject

Returns the value of attribute extra.



61
62
63
# File 'lib/detroit-minitest.rb', line 61

def extra
  @extra
end

#ignoreObject

Test files to ignore by matching filename.



37
38
39
# File 'lib/detroit-minitest.rb', line 37

def ignore
  @ignore
end

#loadpathObject

Returns the value of attribute loadpath.



45
46
47
# File 'lib/detroit-minitest.rb', line 45

def loadpath
  @loadpath
end

#requiresObject

Returns the value of attribute requires.



53
54
55
# File 'lib/detroit-minitest.rb', line 53

def requires
  @requires
end

#testsObject

Test files to include.



21
22
23
# File 'lib/detroit-minitest.rb', line 21

def tests
  @tests
end

Class Method Details

.man_pageObject



121
122
123
# File 'lib/detroit-minitest.rb', line 121

def self.man_page
  File.dirname(__FILE__)+'/../man/detroit-minitest.5'      
end

Instance Method Details

#station_testObject



66
67
68
# File 'lib/detroit-minitest.rb', line 66

def station_test
  test
end

#testObject

Run tests.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/detroit-minitest.rb', line 73

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