Sha256: 4c7f0357b8d9052a99b5dc8fb45d72a0a5bee5adcf1f22e7e613254acc4b86d2

Contents?: true

Size: 827 Bytes

Versions: 5

Compression:

Stored size: 827 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
require 'rbbt/util/filecache'
require 'rbbt-util'
require 'test/unit'

class TestFileCache < Test::Unit::TestCase

  def test_path
    assert_equal(File.join(Rbbt.cachedir,'3','2','1','123.ext'), FileCache.path('123.ext'))
  end

  def test_add_read
    filename = '123.ext'
    content = 'test'

    FileCache.add(filename, content)
    assert_equal(content, File.open(FileCache.path(filename)).read)
    assert_equal(content, FileCache.get(filename).read)

    FileCache.del(filename)
  end

  def test_add_io
    filename = '123.ext'
    content =<<-EOF
test test test
test test test
    EOF

    FileCache.add(filename, StringIO.new(content))
    assert_equal(content, File.open(FileCache.path(filename)).read)

    FileCache.del(filename)
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rbbt-util-2.1.0 test/rbbt/util/test_filecache.rb
rbbt-util-2.0.1 test/rbbt/util/test_filecache.rb
rbbt-util-1.2.1 test/rbbt/util/test_filecache.rb
rbbt-util-1.1.0 test/rbbt/util/test_filecache.rb
rbbt-util-1.0.1 test/rbbt/util/test_filecache.rb