class Test::Unit::Collector::TestDir
Public Instance Methods
create_test(name)
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 345 def create_test(name) t = Class.new(TestCase) t.class_eval <<-EOC self.test_order = :alphabetic def self.name "T\#{#{name}}" end def test_#{name}a end def test_#{name}b end EOC t end
setup()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 321 def setup @t1 = t1 = create_test(1) @t2 = t2 = create_test(2) @t3 = t3 = create_test(3) @t4 = t4 = create_test(4) @t5 = t5 = create_test(5) @t6 = t6 = create_test(6) fs = FileSystem.new do file 'test_1.rb', t1 file 'test_2.rb', t2 dir 'd1' do file 'test_3.rb', t3 end file 't4.rb', t4 dir 'd2' do file 'test_5', t5 file 'test_6.rb', Time end file 't6.rb', t6 end fs.require('t6') @c = Dir.new(fs, fs, fs.object_space, fs) end
test_collect_file()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 373 def test_collect_file expected = TestSuite.new('test_1.rb') expected << @t1.suite assert_equal(expected, @c.collect('test_1.rb')) expected = TestSuite.new('t4.rb') expected << @t4.suite assert_equal(expected, @c.collect('t4.rb')) end
test_collect_multi()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 397 def test_collect_multi expected = TestSuite.new('[d1, d2]') expected << (TestSuite.new('d1') << @t3.suite) expected << (TestSuite.new('d2') << @t5.suite) @c.pattern.replace([/\btest_/]) assert_equal(expected, @c.collect('d1', 'd2')) end
test_dir()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 182 def test_dir inner_dir = nil dirs = FileSystem::Directory.new('/', nil) do file 'a', nil inner_dir = dir 'b' end assert_equal(inner_dir, dirs['b']) end
test_filtering()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 390 def test_filtering expected = TestSuite.new('.') expected << @t1.suite @c.filter = proc{|t| t.method_name == 'test_1a' || t.method_name == 'test_1b'} assert_equal(expected, @c.collect) end
test_fs()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 191 def test_fs fs = FileSystem.new do file 'a', nil dir 'b' end assert_equal(['.', '..', 'a', 'b'].sort, fs.entries('/').sort) assert(fs.directory?('/')) assert(!fs.directory?('/a')) assert(!fs.directory?('/bogus')) assert(fs.file?('/a')) assert(!fs.file?('/')) assert(!fs.file?('/bogus')) assert(fs.directory?('/b')) assert(fs.file?('a')) assert(fs.directory?('b')) end
test_fs_entries()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 249 def test_fs_entries fs = FileSystem.new do file 'a', nil dir 'b' do file 'c', nil file 'd', nil end file 'e', nil dir 'f' do file 'g', nil dir 'h' do file 'i', nil end end end assert_equal(['.', '..', 'a', 'b', 'e', 'f'], fs.entries('/').sort) assert_equal(['.', '..', 'a', 'b', 'e', 'f'], fs.entries('.').sort) assert_equal(['.', '..', 'a', 'b', 'e', 'f'], fs.entries('b/..').sort) assert_equal(['.', '..', 'c', 'd'], fs.entries('b').sort) assert_raises(Errno::ENOENT) do fs.entries('z') end assert_raises(Errno::ENOTDIR) do fs.entries('a') end fs.chdir('f') assert_equal(['.', '..', 'i'], fs.entries('h').sort) end
test_fs_pwd()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 222 def test_fs_pwd fs = FileSystem.new do file 'a', nil dir 'b' do file 'c', nil dir 'd' do file 'e', nil end end end assert_equal('/', fs.pwd) assert_raises(Errno::ENOENT) do fs.chdir('bogus') end assert_raises(Errno::ENOTDIR) do fs.chdir('a') end fs.chdir('b') assert_equal('/b', fs.pwd) fs.chdir('d') assert_equal('/b/d', fs.pwd) fs.chdir('..') assert_equal('/b', fs.pwd) fs.chdir('..') assert_equal('/', fs.pwd) end
test_fs_require()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 282 def test_fs_require fs = FileSystem.new do file 'test_class1.rb', TestClass1 dir 'dir' do file 'test_class2.rb', TestClass2 end end c = [] fs.object_space.each_object(Class) do |o| c << o end assert_equal([], c) assert_raises(LoadError) do fs.require('bogus') end assert(fs.require('test_class1.rb')) assert(!fs.require('test_class1.rb')) c = [] fs.object_space.each_object(Class) do |o| c << o end assert_equal([TestClass1], c) fs.require('dir/test_class2') c = [] fs.object_space.each_object(Class) do |o| c << o end assert_equal([TestClass1, TestClass2], c) c = [] fs.object_space.each_object(Time) do |o| c << o end assert_equal([], c) end
test_fs_sub()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 208 def test_fs_sub fs = FileSystem.new do dir 'a' do file 'b', nil dir 'c' do file 'd', nil end end end assert(fs.file?('/a/b')) assert(!fs.file?('/a/b/c/d')) assert(fs.file?('/a/c/d')) end
test_multilevel_collect()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 366 def test_multilevel_collect expected = TestSuite.new('.') expected << @t1.suite << @t2.suite expected << (TestSuite.new('d1') << @t3.suite) assert_equal(expected, @c.collect) end
test_nil_pattern()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 383 def test_nil_pattern expected = TestSuite.new('d2') expected << @t5.suite @c.pattern.clear assert_equal(expected, @c.collect('d2')) end
test_simple_collect()
click to toggle source
# File test-unit-3.3.4/test/collector/test_dir.rb, line 360 def test_simple_collect expected = TestSuite.new('d1') expected << (@t3.suite) assert_equal(expected, @c.collect('d1')) end