Sha256: 42a778a3933eda09be31b2044525075bddef81854ec7d42624c9b5ef90dec1ef

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

  #  _____         _
  # |_   _|__  ___| |_
  #   | |/ _ \/ __| __|
  #   | |  __/\__ \ |
  #   |_|\___||___/\__|
  #
  # for lib/facets/file/topath.rb
  #
  # Extracted Mon Sep 03 16:23:07 -0700 2007
  # w/ Test Extraction Ratchet
  #

 require 'facets/file/topath.rb'



  require 'test/unit'

  # mock file

  class File
    def self.open( fname, mode, &blk )
      blk.call(self)
    end
    def self.read( fname=nil )
      @mock_content.clone
    end
    def self.write( str )
      @mock_content = str
    end
    def self.<<( str )
      (@mock_content ||="") << str
    end
  end

  # tests

  class TestFile < Test::Unit::TestCase

    # TODO Write file identity tests.

    def test_sanitize_01
      assert_equal( "This_is_a_test", File.sanitize('This is a test') )
    end

    def test_sanitize_02
      assert_equal( "test", File.sanitize('This\is\test') )
    end

    def test_sanitize_03
      assert_equal( "test", File.sanitize('This/is/test') )
    end

    def test_sanitize_04
      assert_equal( "te_____st", File.sanitize('This/te#$#@!st') )
    end

    def test_sanitize_05
      assert_equal( "_.", File.sanitize('.') )
    end

    def test_sanitize_06
      assert_equal( "_....", File.sanitize('....') )
    end

    def test_split_all
      fp = "this/is/test"
      assert_equal( ['this', 'is', 'test'], File.split_all(fp) )
    end

  end



Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.0.0 test/unit/file/test_topath.rb
facets-2.0.1 test/unit/file/test_topath.rb
facets-2.0.2 test/unit/file/test_topath.rb