Sha256: 61afb76808a01e2bd833748e9a799deadfae014eec73eaf9e729cd2641ae045e

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

require 'test_helper'
require 'tilt'

class TiltCacheTest < Minitest::Test
  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
    result = @cache.fetch('hello', {:foo => 'bar', :baz => 'bizzle'}) { template = Tilt::StringTemplate.new {''} }
    assert_same template, result
    result = @cache.fetch('hello', {:foo => 'bar', :baz => 'bizzle'}) { 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

8 entries across 8 versions & 4 rubygems

Version Path
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/tilt-2.0.1/test/tilt_cache_test.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/tilt-2.0.1/test/tilt_cache_test.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/tilt-2.0.1/test/tilt_cache_test.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/tilt-2.0.1/test/tilt_cache_test.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/tilt-2.0.1/test/tilt_cache_test.rb
tilt-2.0.1 test/tilt_cache_test.rb
tilt-2.0.0 test/tilt_cache_test.rb
tilt-2.0.0.beta1 test/tilt_cache_test.rb