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 and directories 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
34
35
36
37
38
# File 'lib/tap/test/extensions.rb', line 26

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

  options = {
    :root => test_root_dir,
    :directories => {
      :input => 'input',
      :output => 'output',
      :expected => 'expected'}
  }.merge(options)

  self.class_test_root = Tap::Root.new(options[:root], options[:directories])
end

#acts_as_script_test(options = {}) ⇒ Object



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

def acts_as_script_test(options={})
  acts_as_file_test({:root => test_root_dir}.merge(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.



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

def acts_as_tap_test(options={})
  acts_as_subset_test
  acts_as_file_test({:root => test_root_dir}.merge(options))

  include Tap::Test::TapTest
end