Module: Tap::Test

Defined in:
lib/tap/test.rb,
lib/tap/test/env.rb,
lib/tap/test/utils.rb,
lib/tap/test/tracer.rb,
lib/tap/test/version.rb,
lib/tap/test/tap_test.rb,
lib/tap/test/file_test.rb,
lib/tap/test/shell_test.rb,
lib/tap/test/subset_test.rb,
lib/tap/test/file_test/class_methods.rb,
lib/tap/test/shell_test/regexp_escape.rb,
lib/tap/test/subset_test/class_methods.rb

Overview

Tap::Test provides several convenience methods for including and setting up Tap::Test modules. The manual use of this module looks like this:

class SampleTest < Test::Unit::TestCase
  extend Tap::Test
  acts_as_tap_test
end

The ‘tap/test/unit’ file performs this setup for Test::Unit (ruby < 1.9) and Mini::Test (ruby >= 1.9); simply require it and call the setup methods as necessary.

require 'tap/test/unit'
class SampleTest < Test::Unit::TestCase
  acts_as_tap_test
end

Defined Under Namespace

Modules: FileTest, ShellTest, SubsetTest, TapTest, Utils Classes: Env, Tracer

Constant Summary collapse

MAJOR =
0
MINOR =
7
TINY =
0
VERSION =
"#{MAJOR}.#{MINOR}.#{TINY}"

Instance Method Summary collapse

Instance Method Details

#acts_as_file_test(options = {}) ⇒ Object

Includes FileTest in the calling class and instantiates class_root. Options:

:root:: Specifies the class_root.  String roots are used to 
        instantiate a new Tap::Root.
:cleanup_dirs:: Specifies directories to cleanup under root.

By default acts_as_file_test guesses a root directory using brittle logic that examines caller. Be sure to specify the root directory manually if you call acts_as_file_test from a file that isn’t the test file, or via some proxy method.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/tap/test.rb', line 43

def acts_as_file_test(options={})
  include Tap::Test::FileTest
  
  root = options[:root] || test_root_dir
  root = Tap::Root.new(root) unless root.kind_of?(Tap::Root)
  self.class_root = root
  
  if cleanup_dirs = options[:cleanup_dirs]
    self.cleanup_dirs = cleanup_dirs
  end
end

#acts_as_shell_test(options = nil) ⇒ Object

Includes ShellTest in the calling class. Options are set as the default sh_test_options.



57
58
59
60
# File 'lib/tap/test.rb', line 57

def acts_as_shell_test(options=nil)
  include Tap::Test::ShellTest
  define_method(:sh_test_options) { super().merge(options) } unless options.nil?
end

#acts_as_subset_testObject

Includes SubsetTest in the calling class.



28
29
30
# File 'lib/tap/test.rb', line 28

def acts_as_subset_test
  include Tap::Test::SubsetTest
end

#acts_as_tap_test(options = {}) ⇒ Object

Includes TapTest in the calling class and calls acts_as_file_test. See acts_as_file_test for valid options.



64
65
66
67
68
69
# File 'lib/tap/test.rb', line 64

def acts_as_tap_test(options={})
  options[:root] ||= test_root_dir
  acts_as_file_test(options)
  
  include Tap::Test::TapTest
end