Sha256: eeb101f1cc0fd1db92911626d71a9c5e6ca99e7b08c462b791e404742b8a5b85

Contents?: true

Size: 1.64 KB

Versions: 35

Compression:

Stored size: 1.64 KB

Contents

#####################################################################
# test_tail.rb
#
# Test case for the File.tail method. This test should be run via
# the 'rake test_tail' task.
#####################################################################
require 'rubygems'
gem 'test-unit'

require 'test/unit'
require 'ptools'

class TC_FileTail < Test::Unit::TestCase
   def self.startup
      Dir.chdir('test') if File.exists?('test')
      File.open('test_file1.txt', 'w'){ |fh| 25.times{ |n| fh.puts "line#{n+1}" } }
   end
   
   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
      @expected_tail1 = nil
      @expected_tail2 = nil
   end

   def self.shutdown
      File.delete('test_file1.txt') if File.exists?('test_file1.txt')
   end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
depengine-0.0.31 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.30 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.29 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.28 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.27 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.26 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.25 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.24 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.23 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.22 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.21 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.20 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.19 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
ptools-1.2.3-universal-mingw32 test/test_tail.rb
depengine-0.0.18 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.17 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.16 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.15 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.14 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb
depengine-0.0.13 etc/isolate/ruby-1.8/gems/ptools-1.1.9/test/test_tail.rb