Tests the base functionality that should be identical across all cache stores.
Methods
- T
-
- test_array_as_cache_key,
- test_cache_key,
- test_crazy_key_characters,
- test_delete,
- test_exist,
- test_expires_in,
- test_fetch_multi,
- test_fetch_with_cache_miss,
- test_fetch_with_cache_miss_passes_key_to_block,
- test_fetch_with_cached_nil,
- test_fetch_with_forced_cache_miss,
- test_fetch_without_cache_miss,
- test_hash_as_cache_key,
- test_keys_are_case_sensitive,
- test_multi_with_objects,
- test_nil_exist,
- test_original_store_objects_should_not_be_immutable,
- test_param_as_cache_key,
- test_race_condition_protection,
- test_race_condition_protection_is_limited,
- test_race_condition_protection_is_safe,
- test_race_condition_protection_skipped_if_not_defined,
- test_read_and_write_compressed_large_data,
- test_read_and_write_compressed_nil,
- test_read_and_write_compressed_small_data,
- test_read_multi,
- test_read_multi_with_expires,
- test_really_long_keys,
- test_should_overwrite,
- test_should_read_and_write_false,
- test_should_read_and_write_hash,
- test_should_read_and_write_integer,
- test_should_read_and_write_nil,
- test_should_read_and_write_strings
Instance Public methods
test_array_as_cache_key()
Link
test_cache_key()
Link
test_crazy_key_characters()
Link
# File activesupport/test/caching_test.rb, line 452 def test_crazy_key_characters crazy_key = "#/:*(<+=> )&$%@?;'\"\'`~-" assert @cache.write(crazy_key, "1", :raw => true) assert_equal "1", @cache.read(crazy_key) assert_equal "1", @cache.fetch(crazy_key) assert @cache.delete(crazy_key) assert_equal "2", @cache.fetch(crazy_key, :raw => true) { "2" } assert_equal 3, @cache.increment(crazy_key) assert_equal 2, @cache.decrement(crazy_key) end
test_delete()
Link
test_exist()
Link
test_expires_in()
Link
# File activesupport/test/caching_test.rb, line 388 def test_expires_in time = Time.local(2008, 4, 24) Time.stubs(:now).returns(time) @cache.write('foo', 'bar') assert_equal 'bar', @cache.read('foo') Time.stubs(:now).returns(time + 30) assert_equal 'bar', @cache.read('foo') Time.stubs(:now).returns(time + 61) assert_nil @cache.read('foo') end
test_fetch_multi()
Link
# File activesupport/test/caching_test.rb, line 295 def test_fetch_multi @cache.write('foo', 'bar') @cache.write('fud', 'biz') values = @cache.fetch_multi('foo', 'fu', 'fud') { |value| value * 2 } assert_equal({ 'foo' => 'bar', 'fu' => 'fufu', 'fud' => 'biz' }, values) assert_equal('fufu', @cache.read('fu')) end
test_fetch_with_cache_miss()
Link
test_fetch_with_cache_miss_passes_key_to_block()
Link
# File activesupport/test/caching_test.rb, line 236 def test_fetch_with_cache_miss_passes_key_to_block cache_miss = false assert_equal 3, @cache.fetch('foo') { |key| cache_miss = true; key.length } assert cache_miss cache_miss = false assert_equal 3, @cache.fetch('foo') { |key| cache_miss = true; key.length } assert !cache_miss end
test_fetch_with_cached_nil()
Link
test_fetch_with_forced_cache_miss()
Link
test_fetch_without_cache_miss()
Link
test_hash_as_cache_key()
Link
test_keys_are_case_sensitive()
Link
test_multi_with_objects()
Link
# File activesupport/test/caching_test.rb, line 305 def test_multi_with_objects foo = stub(:title => 'FOO!', :cache_key => 'foo') bar = stub(:cache_key => 'bar') @cache.write('bar', 'BAM!') values = @cache.fetch_multi(foo, bar) { |object| object.title } assert_equal({ foo => 'FOO!', bar => 'BAM!' }, values) end
test_nil_exist()
Link
test_original_store_objects_should_not_be_immutable()
Link
test_param_as_cache_key()
Link
test_race_condition_protection()
Link
# File activesupport/test/caching_test.rb, line 441 def test_race_condition_protection time = Time.now @cache.write('foo', 'bar', :expires_in => 60) Time.stubs(:now).returns(time + 61) result = @cache.fetch('foo', :race_condition_ttl => 10) do assert_equal 'bar', @cache.read('foo') "baz" end assert_equal "baz", result end
test_race_condition_protection_is_limited()
Link
# File activesupport/test/caching_test.rb, line 414 def test_race_condition_protection_is_limited time = Time.now @cache.write('foo', 'bar', :expires_in => 60) Time.stubs(:now).returns(time + 71) result = @cache.fetch('foo', :race_condition_ttl => 10) do assert_equal nil, @cache.read('foo') "baz" end assert_equal "baz", result end
test_race_condition_protection_is_safe()
Link
# File activesupport/test/caching_test.rb, line 425 def test_race_condition_protection_is_safe time = Time.now @cache.write('foo', 'bar', :expires_in => 60) Time.stubs(:now).returns(time + 61) begin @cache.fetch('foo', :race_condition_ttl => 10) do assert_equal 'bar', @cache.read('foo') raise ArgumentError.new end rescue ArgumentError end assert_equal "bar", @cache.read('foo') Time.stubs(:now).returns(time + 91) assert_nil @cache.read('foo') end
test_race_condition_protection_skipped_if_not_defined()
Link
# File activesupport/test/caching_test.rb, line 402 def test_race_condition_protection_skipped_if_not_defined @cache.write('foo', 'bar') time = @cache.send(:read_entry, 'foo', {}).expires_at Time.stubs(:now).returns(Time.at(time)) result = @cache.fetch('foo') do assert_equal nil, @cache.read('foo') 'baz' end assert_equal 'baz', result end
test_read_and_write_compressed_large_data()
Link
test_read_and_write_compressed_nil()
Link
test_read_and_write_compressed_small_data()
Link
test_read_multi()
Link
test_read_multi_with_expires()
Link
# File activesupport/test/caching_test.rb, line 286 def test_read_multi_with_expires time = Time.now @cache.write('foo', 'bar', :expires_in => 10) @cache.write('fu', 'baz') @cache.write('fud', 'biz') Time.stubs(:now).returns(time + 11) assert_equal({"fu" => "baz"}, @cache.read_multi('foo', 'fu')) end
test_really_long_keys()
Link
# File activesupport/test/caching_test.rb, line 463 def test_really_long_keys key = "" 900.times{key << "x"} assert @cache.write(key, "bar") assert_equal "bar", @cache.read(key) assert_equal "bar", @cache.fetch(key) assert_nil @cache.read("#{key}x") assert_equal({key => "bar"}, @cache.read_multi(key)) assert @cache.delete(key) end
test_should_overwrite()
Link
test_should_read_and_write_false()
Link
test_should_read_and_write_hash()
Link
test_should_read_and_write_integer()
Link
test_should_read_and_write_nil()
Link