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



132
133
134
# File 'lib/detroit-minitest.rb', line 132

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

Instance Method Details

#assemble(station, options = {}) ⇒ Object



74
75
76
77
78
# File 'lib/detroit-minitest.rb', line 74

def assemble(station, options={})
  case station
  when :test then test
  end
end

#assemble?(station, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
70
71
# File 'lib/detroit-minitest.rb', line 67

def assemble?(station, options={})
  case station
  when :test then true
  end
end

#testObject

Run tests.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# 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