Module: Tap::Test

Defined in:
lib/tap/test.rb,
lib/tap/test/utils.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/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.

Defined Under Namespace

Modules: FileTest, ShellTest, SubsetTest, TapTest, Utils

Constant Summary collapse

MAJOR =
0
MINOR =
3
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 instantiating class_test_root (a Tap::Root). Options may be used to configure the class_test_root.

Note: by default acts_as_file_test determines a root directory based on the calling file. Be sure to specify the root directory manually if you call acts_as_file_test from a file that isn’t the test file.



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/tap/test.rb', line 37

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

#acts_as_shell_test(options = nil) ⇒ Object

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



51
52
53
54
# File 'lib/tap/test.rb', line 51

def acts_as_shell_test(options=nil)
  include Tap::Test::ShellTest
  self.sh_test_options.merge!(options) if options
end

#acts_as_subset_testObject

Includes SubsetTest in the calling class.



26
27
28
# File 'lib/tap/test.rb', line 26

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 with the options.



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

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