| Class | Webgen::TestCase |
| In: |
lib/webgen/test.rb
|
| Parent: | Test::Unit::TestCase |
Base class for all webgen test cases. It specifies some auxilary methods helpful when developing tests.
Returns the base fixture path for the test case. If filename is specified, it is appended to the base fixture path.
# File lib/webgen/test.rb, line 58
58: def self.base_fixture_path( filename = nil )
59: path_helper( :@base_fixture_path, filename )
60: end
If filename is not specified, returns the fixture path for the test case. If filename is specified, it is appended to the fixture path.
# File lib/webgen/test.rb, line 47
47: def self.fixture_path( filename = nil )
48: path_helper( :@fixture_path, filename )
49: end
Sets the base fixture path and the fixture path for the test case.
# File lib/webgen/test.rb, line 15
15: def self.inherited( klass )
16: path = caller[0][/^.*?:/][0..-2]
17: dir, file = File.split( path )
18: parent_path, unit_tests = File.split( dir )
19:
20: fpath = if dir == '.'
21: File.join( '..', 'fixtures' )
22: else
23: File.join( parent_path, 'fixtures' )
24: end
25:
26: klass.instance_variable_set( :@fixture_path, File.join( fpath, File.basename( file, '.*' ) ) )
27: klass.instance_variable_set( :@base_fixture_path, fpath + '/' )
28: end
Helper method for retrieving a path name with an optionally appended filename.
# File lib/webgen/test.rb, line 40
40: def self.path_helper( var, filename = nil )
41: var = instance_variable_get( var )
42: (filename.nil? ? var : File.join( var, filename ) )
43: end
Reimplemented to hide the base test case.
# File lib/webgen/test.rb, line 31
31: def self.suite
32: if self == TestCase
33: return Test::Unit::TestSuite.new('Webgen::TestCase')
34: else
35: super
36: end
37: end
See TestCase.base_fixture_path
# File lib/webgen/test.rb, line 63
63: def base_fixture_path( filename = nil )
64: self.class.base_fixture_path( filename )
65: end