| Class | CoreEx::PathnameExTest |
| In: |
lib/core_ex/pathname.rb
|
| Parent: | Test::Unit::TestCase |
# File lib/core_ex/pathname.rb, line 235 def setup @test = __FILE__.to_path.dirname.parent.parent + 'test' @fixtures = @test + 'fixtures' @req = @fixtures + 'require' @s = 'test_require' @s_dne = 'test_require_dne' @s_so = 'test_require_so.so' @s_rb = 'test_require_rb.rb' @p = @s.to_path @p_dne = @s_dne.to_path @p_so = @s_so.to_path @p_rb = @s_rb.to_path @ls = [ @s, @s_dne, @s_so, @s_rb ] @lp = [ @p, @p_dne, @p_rb ] # FIXME @p_so on mac @l = @ls + @lp @load_path = $LOAD_PATH end
# File lib/core_ex/pathname.rb, line 288 def test_1_expand_path_with @lp.each { |x| assert_expand_path_with(x, nil) } end
# File lib/core_ex/pathname.rb, line 292 def test_2_expand_path_with @load_path << @req @lp.delete(@p_dne) @lp.each { |x| assert_expand_path_with(x, @req + x) } @lp.each { |x| assert_expand_path_with(@req + x, @req + x) } assert_expand_path_with(@p_dne, nil) end
Tests
# File lib/core_ex/pathname.rb, line 256 def test_ensure_dir p = nil begin name = Tempfile.new('pathname') p = name.path.to_path name.delete assert(! p.directory?, 'no directory') assert_nothing_raised { p.ensure_mkdir } assert(p.directory?, 'directory') assert_nothing_raised { p.ensure_mkdir } assert(p.directory?, 'still directory') ensure p.rmdir unless p.nil? end end
# File lib/core_ex/pathname.rb, line 274 def test_simple assert_equal([`path.ext1`, '.ext2'], `path.ext1.ext2`.extsplit) assert_equal([`path`, ''], `path`.extsplit) assert_equal([`path`, '.'], `path.`.extsplit) assert_equal([`path`, '-ext'], `path-ext`.extsplit('-')) assert_equal([`path-ext1`, '-ext2'], `path-ext1-ext2`.extsplit('-')) end
# File lib/core_ex/pathname.rb, line 282 def test_slash assert_equal(`path/to/a/file`, `path`/'to'/'a'/'file') path, to, a, file = `/path`, 'to', 'a', 'file' assert_equal(`/path/to/a/file`, path/to/a/file) end