Sha256: 9c49d756b5820bdcdb86d9ef815990ef21a4b59939d28c2288addc325973b695

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

require 'contest'
require 'tilt'

class TiltCacheTest < Test::Unit::TestCase
  setup { @cache = Tilt::Cache.new }

  test "caching with single simple argument to #fetch" do
    template = nil
    result = @cache.fetch('hello') { template = Tilt::StringTemplate.new {''} }
    assert_same template, result
    result = @cache.fetch('hello') { fail 'should be cached' }
    assert_same template, result
  end

  test "caching with multiple complex arguments to #fetch" do
    template = nil
    args = ['hello', {:foo => 'bar', :baz => 'bizzle'}]
    result = @cache.fetch(*args) { template = Tilt::StringTemplate.new {''} }
    assert_same template, result
    result = @cache.fetch(*args) { fail 'should be cached' }
    assert_same template, result
  end

  test "clearing the cache with #clear" do
    template, other = nil
    result = @cache.fetch('hello') { template = Tilt::StringTemplate.new {''} }
    assert_same template, result

    @cache.clear
    result = @cache.fetch('hello') { other = Tilt::StringTemplate.new {''} }
    assert_same other, result
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tilt-1.0.1 test/tilt_cache_test.rb
tilt-1.0 test/tilt_cache_test.rb
tilt-0.10 test/tilt_cache_test.rb
tilt-0.9 test/tilt_cache_test.rb
tilt-0.8 test/tilt_cache_test.rb
tilt-0.7 test/tilt_cache_test.rb
tilt-0.6 test/tilt_cache_test.rb
tilt-0.5 test/tilt_cache_test.rb
tilt-0.4 test/tilt_cache_test.rb