Sha256: f50020a5e9e2ae65c25e62b28593421d6c0afaab32b0946ea9eb353643de1b3f

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 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')

require 'scout/resource/scout'

class TestResourceUtil < Test::Unit::TestCase
  def test_identify
    path = Path.setup('share/data/somedir/somepath').find
    assert_equal 'share/data/somedir/somepath', Scout.identify(path)
  end

  def test_identify_with_subdir
    m = Module.new
    m.extend Resource
    m.subdir = 'test/subdir'
    path = m.root['share/data/somedir/somepath'].find
    assert_equal 'share/data/somedir/somepath', m.identify(path)
  end


  def test_relocate
    TmpFile.with_file do |dir|
      Path.setup dir

      path_base = Path.setup("basedir").someother.file
      path_base.path_maps[:subdir1] = File.join(dir, 'subdir1', '{PATH}')
      path_base.path_maps[:subdir2] = File.join(dir, 'subdir2', '{PATH}')

      path1 = path_base.find(:subdir1)
      path2 = path_base.find(:subdir2)

      Open.write(path1, "TEST")
      Open.mv path1, path2
      assert_equal path2, Resource.relocate(path1)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scout-essentials-1.0.0 test/scout/resource/test_util.rb