class TestUtilPathname
Public Instance Methods
test_all()
click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 88 def test_all # test_string_path assert_instance_of Pathname, 't'.path assert_equal 't', 't'.path.to_s # test_path_path assert_instance_of Pathname, 't'.path.path # test_to_win_dir assert_equal 'c:/t', '/cygdrive/c/t'.path.to_win_dir # test_extname assert_equal '', 't'.path.extname assert_equal '.txt', 't.txt'.path.extname assert_equal '.gz', 't.tar.gz'.path.extname # test_ext assert_equal 'txt', 't.txt'.path.ext assert_equal 'gz', 't.tar.gz'.path.ext # test_write 'test.txt'.path.write('t') # test_read assert_equal 't', 'test.txt'.path.read # test_append 'test.txt'.path.append('t') assert_equal 'tt', 'test.txt'.path.read # test_get_first 'test.txt'.path.write("s\nt\n") assert_equal "s\nt\n", 'test.txt'.path.read assert_equal "s\n", 'test.txt'.path.get_first # teardown assert_equal true, 'test.txt'.path.exist? 'test.txt'.path.unlink assert_equal false, 'test.txt'.path.exist? end
test_chdir()
click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 194 def test_chdir pwd = Dir.pwd Dir.chdir('/') { assert_not_equal(pwd, Dir.pwd) } assert_equal pwd, Dir.pwd end
test_check_directory()
click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 129 def test_check_directory return if $0 != __FILE__ # Only for unit test. dir = 'testdir'.path dir.erase_all if dir.exist? dir.rmtree if dir.exist? dir.rmdir if dir.exist? assert_equal false, dir.exist? dir.check_directory assert_equal true, dir.exist? dir.check_directory # Check again cause no error. assert_equal true, dir.exist? dir.erase_all dir.rmdir assert_equal false, dir.exist? end
test_check_directory_raise()
click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 149 def test_check_directory_raise return if $0 != __FILE__ # Only for unit test. # Make a plain text file. file = 't.txt'.path file.write('t') # Try to create a directory with the same name cause exception. assert_raise(RuntimeError) { file.check_directory } file.unlink end
test_check_pathname()
click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 179 def test_check_pathname dir = 'testdir'.path dir.rmtree if dir.exist? dir.rmdir if dir.exist? dir.mkdir assert_equal true, dir.exist? file = dir+'t' file.write('test string') assert_equal true, file.exist? dir.rmtree assert_equal false, dir.exist? end
test_erase_all()
click to toggle source
# File vendor/qwik/lib/qwik/util-pathname.rb, line 163 def test_erase_all dir = 'testdir'.path dir.check_directory # mkdir file = 'testdir/t.txt'.path # Create a dummy file. file.write('t') assert_equal true, file.exist? dir.erase_all assert_equal false, file.exist? # The file is deleted. assert_equal true, dir.exist? # But the directory is remained here. dir.rmdir assert_equal false, dir.exist? end