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.rb70
1 files changed, 15 insertions, 55 deletions
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index 0af4251962..c5f7fb7fdd 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -71,69 +71,29 @@ uses_mocha 'high-level cache store tests' do
end
end
-class ThreadSafetyCacheStoreTest < Test::Unit::TestCase
+class FileStoreTest < Test::Unit::TestCase
def setup
- @cache = ActiveSupport::Cache.lookup_store(:memory_store).threadsafe!
- @cache.write('foo', 'bar')
-
- # No way to have mocha proxy to the original method
- @mutex = @cache.instance_variable_get(:@mutex)
- @mutex.instance_eval %(
- def calls; @calls; end
- def synchronize
- @calls ||= 0
- @calls += 1
- yield
- end
- )
+ @cache = ActiveSupport::Cache.lookup_store(:file_store, Dir.pwd)
end
- def test_read_is_synchronized
+ def test_should_read_and_write_strings
+ @cache.write('foo', 'bar')
assert_equal 'bar', @cache.read('foo')
- assert_equal 1, @mutex.calls
- end
-
- def test_write_is_synchronized
- @cache.write('foo', 'baz')
- assert_equal 'baz', @cache.read('foo')
- assert_equal 2, @mutex.calls
+ ensure
+ File.delete("foo.cache")
end
- def test_delete_is_synchronized
- assert_equal 'bar', @cache.read('foo')
- @cache.delete('foo')
- assert_equal nil, @cache.read('foo')
- assert_equal 3, @mutex.calls
+ def test_should_read_and_write_hash
+ @cache.write('foo', {:a => "b"})
+ assert_equal({:a => "b"}, @cache.read('foo'))
+ ensure
+ File.delete("foo.cache")
end
- def test_delete_matched_is_synchronized
- assert_equal 'bar', @cache.read('foo')
- @cache.delete_matched(/foo/)
+ def test_should_read_and_write_nil
+ @cache.write('foo', nil)
assert_equal nil, @cache.read('foo')
- assert_equal 3, @mutex.calls
- end
-
- def test_fetch_is_synchronized
- assert_equal 'bar', @cache.fetch('foo') { 'baz' }
- assert_equal 'fu', @cache.fetch('bar') { 'fu' }
- assert_equal 3, @mutex.calls
- end
-
- def test_exist_is_synchronized
- assert @cache.exist?('foo')
- assert !@cache.exist?('bar')
- assert_equal 2, @mutex.calls
- end
-
- def test_increment_is_synchronized
- @cache.write('foo_count', 1)
- assert_equal 2, @cache.increment('foo_count')
- assert_equal 4, @mutex.calls
- end
-
- def test_decrement_is_synchronized
- @cache.write('foo_count', 1)
- assert_equal 0, @cache.decrement('foo_count')
- assert_equal 4, @mutex.calls
+ ensure
+ File.delete("foo.cache")
end
end