Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (28 sloc) 1.05 KB
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
Something went wrong with that request. Please try again.