Sha256: 76af40f141a7a36ceabc540103ac82699161a270894b6f56664c876c687084eb
Contents?: true
Size: 1.39 KB
Versions: 3
Compression:
Stored size: 1.39 KB
Contents
######################################## # tc_tail.rb # # Test case for the File.tail method. ######################################## base = File.basename(Dir.pwd) if base == "test" or base =~ /ptools/ Dir.chdir("..") if base == "test" $LOAD_PATH.unshift(Dir.pwd) $LOAD_PATH.unshift(Dir.pwd + "/lib") Dir.chdir("test") if Dir.pwd != "test" end require "test/unit" require "ptools" class TC_FileTail < Test::Unit::TestCase def setup @test_file = 'test_file1.txt' @expected_tail1 = ["line16\n","line17\n","line18\n","line19\n"] @expected_tail1.push("line20\n","line21\n","line22\n", "line23\n") @expected_tail1.push("line24\n","line25\n") @expected_tail2 = ["line21\n","line22\n","line23\n","line24\n","line25\n"] end def test_tail_basic assert_respond_to(File, :tail) assert_nothing_raised{ File.tail(@test_file) } assert_nothing_raised{ File.tail(@test_file, 5) } assert_nothing_raised{ File.tail(@test_file){} } end def test_tail_expected_return_values assert_kind_of(Array, File.tail(@test_file)) assert_equal(@expected_tail1, File.tail(@test_file)) assert_equal(@expected_tail2, File.tail(@test_file, 5)) end def test_tail_expected_errors assert_raises(ArgumentError){ File.tail } assert_raises(ArgumentError){ File.tail(@test_file, 5, 5) } end def teardown @test_file = nil end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ptools-1.0.0 | test/tc_tail.rb |
ptools-1.1.0 | test/tc_tail.rb |
ptools-1.1.1 | test/tc_tail.rb |