Sha256: 46b7c1eca6c1f448c71e724cd8144179fb0373230daa522564e2a1415abf1047

Contents?: true

Size: 1.25 KB

Versions: 12

Compression:

Stored size: 1.25 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'
require 'scout/resource/scout'

class TestResourcePath < Test::Unit::TestCase
  module TestResource
    extend Resource

    self.subdir = Path.setup('tmp/test-resource_alt')

    claim self.tmp.test.string, :string, "TEST"
  end

  def teardown
    FileUtils.rm_rf TestResource.root.find
  end

  def test_read
    assert_include TestResource.tmp.test.string.read, "TEST"
  end

  def test_open
    str = ""
    TestResource.tmp.test.string.open do |f|
      str = f.read
    end
    assert_include str, "TEST"
  end

  def test_write
    TmpFile.with_file do |tmpfile|
      Path.setup(tmpfile)
      tmpfile.foo.bar.write do |f|
        f.puts "TEST"
      end
      assert_include tmpfile.foo.bar.read, "TEST"
    end
  end

  def test_identify
    p = Scout.data.file.find(:lib)
    assert p.located?
    assert_equal "data/file", p.identify
  end

  def test_with_extension
    dir = tmpdir.directory[__method__]
    list = %w(a b)
    Misc.in_dir(dir) do
      file = dir.foo
      Open.write(file.set_extension('list'), list * "\n")
      assert_equal list, file.list
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
scout-essentials-1.6.5 test/scout/resource/test_path.rb
scout-essentials-1.6.4 test/scout/resource/test_path.rb
scout-essentials-1.6.3 test/scout/resource/test_path.rb
scout-essentials-1.6.2 test/scout/resource/test_path.rb
scout-essentials-1.6.1 test/scout/resource/test_path.rb
scout-essentials-1.6.0 test/scout/resource/test_path.rb
scout-essentials-1.3.1 test/scout/resource/test_path.rb
scout-essentials-1.3.0 test/scout/resource/test_path.rb
scout-essentials-1.2.0 test/scout/resource/test_path.rb
scout-essentials-1.1.1 test/scout/resource/test_path.rb
scout-essentials-1.1.0 test/scout/resource/test_path.rb
scout-essentials-1.0.0 test/scout/resource/test_path.rb