Sha256: effb8bbea3f9604f057b8445307e687df4c7ff7f478dc261063316edd5bc4efe

Contents?: true

Size: 1.01 KB

Versions: 16

Compression:

Stored size: 1.01 KB

Contents

require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')

class TestFilesystem < Test::Unit::TestCase
  def test_in_dir
    TmpFile.with_file do |tmpdir|
      Misc.in_dir tmpdir do
        assert_equal tmpdir, FileUtils.pwd
      end
    end
  end

  def test_relative
    assert_equal 'bar', Misc.path_relative_to("/tmp/foo", "/tmp/foo/bar")
    assert_equal 'bar/other', Misc.path_relative_to("/tmp/foo", "/tmp/foo/bar/other")

    refute Misc.path_relative_to("/tmp/bar", "/tmp/foo/bar/other")
    refute Misc.path_relative_to("/tmp/foo", "tmp/foo/bar/other")

    TmpFile.with_file do |tmpdir|
      Misc.in_dir tmpdir do
        assert Misc.path_relative_to(tmpdir, "foo")
        assert Misc.path_relative_to(tmpdir, File.join(tmpdir, "foo"))
      end
      assert Misc.path_relative_to(tmpdir, File.join(tmpdir, "foo"))
      assert Misc.path_relative_to(File.dirname(tmpdir), File.join(tmpdir, "foo"))
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
scout-essentials-1.3.1 test/scout/misc/test_filesystem.rb
scout-essentials-1.3.0 test/scout/misc/test_filesystem.rb
scout-essentials-1.2.0 test/scout/misc/test_filesystem.rb
scout-essentials-1.1.1 test/scout/misc/test_filesystem.rb
scout-essentials-1.1.0 test/scout/misc/test_filesystem.rb
scout-essentials-1.0.0 test/scout/misc/test_filesystem.rb
scout-gear-9.1.0 test/scout/misc/test_filesystem.rb
scout-gear-9.0.0 test/scout/misc/test_filesystem.rb
scout-gear-8.1.0 test/scout/misc/test_filesystem.rb
scout-gear-8.0.0 test/scout/misc/test_filesystem.rb
scout-gear-7.3.0 test/scout/misc/test_filesystem.rb
scout-gear-7.2.0 test/scout/misc/test_filesystem.rb
scout-gear-7.1.0 test/scout/misc/test_filesystem.rb
scout-gear-6.0.0 test/scout/misc/test_filesystem.rb
scout-gear-5.2.0 test/scout/misc/test_filesystem.rb
scout-gear-5.1.1 test/scout/misc/test_filesystem.rb