Sha256: a0b5fabb47b32fb67f26f71e2057f99722c416536722f89bbb02e9e88c1a816c
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
$:.unshift(File.dirname(__FILE__)) require "test_helper" require "caching_test" module CacheTagsBehavior def test_read_and_write_with_tags @cache.write("foo", "bar", :tags => "baz") assert_equal 'bar', @cache.read('foo') end def test_read_after_tag_deleted @cache.write("foo", "bar", :tags => "baz") @cache.delete_tag("baz") assert_nil @cache.read("foo") end def test_read_after_another_tag_deleted @cache.write("foo", "bar", :tags => "baz") @cache.delete_tag("fu") assert_equal 'bar', @cache.read('foo') end def test_read_and_write_with_multiple_tags @cache.write("foo", "bar", :tags => [:baz, :kung]) assert_equal 'bar', @cache.read('foo') end def test_read_after_one_of_tags_deleted @cache.write("foo", "bar", :tags => [:baz, :kung]) @cache.delete_tag :kung assert_nil @cache.read("foo") end def test_read_after_another_of_multiple_tags_deleted @cache.write("foo", "bar", :tags => [:baz, :kung]) @cache.delete_tag("fu") assert_equal 'bar', @cache.read('foo') end def test_read_with_small_default_expiration_time cache = if is_a?(FileStoreTest) @cache.class.new @cache.cache_path, :expires_in => 0.001 else @cache.class.new :expires_in => 0.001 end cache.write("foo", "bar", :tags => "baz", :expires_in => 2) sleep 0.02 assert_equal 'bar', cache.read('foo') end def test_exists_with_tags @cache.write("foo", "bar", :tags => "baz") @cache.delete_tag("baz") assert_equal @cache.exist?("foo"), false end def test_read_and_write_with_tags_hash @cache.write("foo", "bar", :tags => {:baz => 1}) assert_equal 'bar', @cache.read('foo') end def test_read_and_write_with_tags_hash_after_expiration @cache.write("foo", "bar", :tags => {:baz => 1}) @cache.delete_tag :baz => 1 assert_nil @cache.read('foo') end end [FileStoreTest, MemoryStoreTest, MemCacheStoreTest].each do |klass| klass.send :include, CacheTagsBehavior end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails-cache-tags-1.0.0 | test/cache_tags_test.rb |