Sha256: abd47f361ae698a4daa2b6e3633cd1c4a1530daa2bea27587168289aed78eb60

Contents?: true

Size: 1.52 KB

Versions: 9

Compression:

Stored size: 1.52 KB

Contents

require 'rubygems'
require 'tzinfo'
require 'test/unit'
require 'fileutils'
require File.join(File.dirname(__FILE__), '../../lib/zena/core_ext/string')
require File.join(File.dirname(__FILE__), '../../lib/zena/core_ext/fixnum')
require File.join(File.dirname(__FILE__), '../../lib/zena/core_ext/dir')

class StringExtTest < Test::Unit::TestCase
  def test_abs_rel_path
    {
      'a/b/c/d' => 'd',
      'a/x'     => '../../x',
      'y/z'     => '../../../y/z',
      'a/b/d'   => '../d',
      'a/b/c'   => '',
      }.each do |orig, test_rel|
        rel = orig.rel_path('a/b/c')
        assert_equal rel, test_rel, "'#{orig}' should become the relative path '#{test_rel}'"
        abs = rel.abs_path('a/b/c')
        assert_equal rel, test_rel, "'#{rel}' should become the absolute path '#{orig}'"
    end

    {
      'a/b/c/d' => 'a/b/c/d',
      'a/x'     => 'a/x',
      }.each do |orig, test_rel|
        rel = orig.rel_path('')
        assert_equal rel, test_rel, "'#{orig}' should become the relative path '#{test_rel}'"
        abs = rel.abs_path('')
        assert_equal rel, test_rel, "'#{rel}' should become the absolute path '#{orig}'"
    end

    assert_equal "/a/b/c", ''.abs_path('/a/b/c')
  end
end

class DirExtTest < Test::Unit::TestCase
  def test_empty?
    name = 'asldkf9032oi09sdflk'
    FileUtils.rmtree(name)
    FileUtils.mkpath(name)
    assert File.exist?(name) && Dir.empty?(name)
    File.open(File.join(name,'hello.txt'), 'wb') {|f| f.puts "hello" }
    assert !Dir.empty?(name)
    FileUtils.rmtree(name)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
zena-0.16.9 test/unit/core_ext_test.rb
zena-1.0.0.beta3 test/unit/core_ext_test.rb
zena-0.16.8 test/unit/core_ext_test.rb
zena-1.0.0.beta2 test/unit/core_ext_test.rb
zena-1.0.0.beta1 test/unit/core_ext_test.rb
zena-0.16.7 test/unit/core_ext_test.rb
zena-0.16.6 test/unit/core_ext_test.rb
zena-0.16.5 test/unit/core_ext_test.rb
zena-0.16.4 test/unit/core_ext_test.rb