aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/caching_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/caching_test.rb')
-rw-r--r--activesupport/test/caching_test.rb44
1 files changed, 24 insertions, 20 deletions
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index cc371b3a7b..d8506de986 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -45,29 +45,27 @@ class CacheStoreSettingTest < Test::Unit::TestCase
end
end
-uses_mocha 'high-level cache store tests' do
- class CacheStoreTest < Test::Unit::TestCase
- def setup
- @cache = ActiveSupport::Cache.lookup_store(:memory_store)
- end
+class CacheStoreTest < Test::Unit::TestCase
+ def setup
+ @cache = ActiveSupport::Cache.lookup_store(:memory_store)
+ end
- def test_fetch_without_cache_miss
- @cache.stubs(:read).with('foo', {}).returns('bar')
- @cache.expects(:write).never
- assert_equal 'bar', @cache.fetch('foo') { 'baz' }
- end
+ def test_fetch_without_cache_miss
+ @cache.stubs(:read).with('foo', {}).returns('bar')
+ @cache.expects(:write).never
+ assert_equal 'bar', @cache.fetch('foo') { 'baz' }
+ end
- def test_fetch_with_cache_miss
- @cache.stubs(:read).with('foo', {}).returns(nil)
- @cache.expects(:write).with('foo', 'baz', {})
- assert_equal 'baz', @cache.fetch('foo') { 'baz' }
- end
+ def test_fetch_with_cache_miss
+ @cache.stubs(:read).with('foo', {}).returns(nil)
+ @cache.expects(:write).with('foo', 'baz', {})
+ assert_equal 'baz', @cache.fetch('foo') { 'baz' }
+ end
- def test_fetch_with_forced_cache_miss
- @cache.expects(:read).never
- @cache.expects(:write).with('foo', 'bar', :force => true)
- @cache.fetch('foo', :force => true) { 'bar' }
- end
+ def test_fetch_with_forced_cache_miss
+ @cache.expects(:read).never
+ @cache.expects(:write).with('foo', 'bar', :force => true)
+ @cache.fetch('foo', :force => true) { 'bar' }
end
end
@@ -160,6 +158,12 @@ uses_memcached 'memcached backed store' do
@cache.read('foo').gsub!(/.*/, 'baz')
assert_equal 'bar', @cache.read('foo')
end
+
+ def test_write_should_return_true_on_success
+ result = @cache.write('foo', 'bar')
+ assert_equal 'bar', @cache.read('foo') # make sure 'foo' was written
+ assert result
+ end
end
class CompressedMemCacheStore < Test::Unit::TestCase