Sha256: fce7eb4ab363d4af97009338b0346395ccd9273a2763888dab41c63de8fd166f
Contents?: true
Size: 1.2 KB
Versions: 7
Compression:
Stored size: 1.2 KB
Contents
# _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ | # |_|\___||___/\__| # # for facets/file/topath.rb require 'facets/file/topath.rb' require 'test/unit' # mock file class MockFile < 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", MockFile.sanitize('This is a test') ) end def test_sanitize_02 assert_equal( "test", MockFile.sanitize('This\is\test') ) end def test_sanitize_03 assert_equal( "test", MockFile.sanitize('This/is/test') ) end def test_sanitize_04 assert_equal( "te_____st", MockFile.sanitize('This/te#$#@!st') ) end def test_sanitize_05 assert_equal( "_.", MockFile.sanitize('.') ) end def test_sanitize_06 assert_equal( "_....", MockFile.sanitize('....') ) end def test_split_all fp = "this/is/test" assert_equal( ['this', 'is', 'test'], MockFile.split_all(fp) ) end end
Version data entries
7 entries across 7 versions & 1 rubygems