Sha256: 612eed9a129cc6eed766853f3eb8cf327cdcc26b283b74d5efbadda107669221

Contents?: true

Size: 1.34 KB

Versions: 101

Compression:

Stored size: 1.34 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 "caching nil" do
    called = false
    result = @cache.fetch("blah") {called = true; nil}
    assert_equal true, called
    assert_nil result
    called = false
    result = @cache.fetch("blah") {called = true; :blah}
    assert_equal false, called
    assert_nil 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

101 entries across 100 versions & 19 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/tilt-2.0.9/test/tilt_cache_test.rb