Module: Tap::Test::Extensions

Included in:
MiniTest::Unit::TestCase, Test::Unit::TestCase
Defined in:
lib/tap/test/extensions.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_file_test(options = {}) ⇒ Object

Causes a TestCase to act as a file test, by including FileTest and instantiating class_test_root (a Tap::Root). The root, relative_paths, and absolute_paths used by class_test_root may be specified as options.

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.



26
27
28
29
30
31
32
33
# File 'lib/tap/test/extensions.rb', line 26

def acts_as_file_test(options={})
  include Tap::Test::FileTest

  self.class_test_root = Tap::Root.new(
    options[:root] || test_root_dir, 
    options[:relative_paths] || {}, 
    options[:absolute_paths] || {})
end

#acts_as_script_test(options = {}) ⇒ Object



53
54
55
56
57
58
# File 'lib/tap/test/extensions.rb', line 53

def acts_as_script_test(options={})
  options[:root] ||= test_root_dir
  acts_as_file_test(options)

  include Tap::Test::ScriptTest
end

#acts_as_subset_testObject



14
15
16
# File 'lib/tap/test/extensions.rb', line 14

def acts_as_subset_test
  include Tap::Test::SubsetTest
end

#acts_as_tap_test(options = {}) ⇒ Object

Causes a unit test to act as a tap test – resulting in the following:

  • setup using acts_as_file_test

  • inclusion of Tap::Test::SubsetTest

  • inclusion of Tap::Test::InstanceMethods

Note: by default acts_as_tap_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.



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

def acts_as_tap_test(options={})
  options[:root] ||= test_root_dir
  
  acts_as_subset_test
  acts_as_file_test(options)

  include Tap::Test::TapTest
end