From 761a633a9c0a45d76ef3ed10da97e3696c3ded79 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 3 Dec 2008 10:57:08 -0600 Subject: Add Memoizable#flush_cache to clear the cache of a specific method [#1505 state:resolved] --- activesupport/test/memoizable_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activesupport/test') diff --git a/activesupport/test/memoizable_test.rb b/activesupport/test/memoizable_test.rb index 33f1e7fe61..069ae27eb2 100644 --- a/activesupport/test/memoizable_test.rb +++ b/activesupport/test/memoizable_test.rb @@ -128,6 +128,16 @@ class MemoizableTest < Test::Unit::TestCase assert_equal 3, @calculator.counter end + def test_flush_cache + assert_equal 1, @calculator.counter + + assert @calculator.instance_variable_get(:@_memoized_counter).any? + @calculator.flush_cache(:counter) + assert @calculator.instance_variable_get(:@_memoized_counter).empty? + + assert_equal 2, @calculator.counter + end + def test_unmemoize_all assert_equal 1, @calculator.counter -- cgit v1.2.3