aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/memoizable_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-08-07 14:55:14 -0500
committerJoshua Peek <josh@joshpeek.com>2008-08-07 14:55:14 -0500
commita8057669ff6ba11e228fc73eef7390b826d0de25 (patch)
treefab205b4b3900d9c9a3ef0f169491ae94d327317 /activesupport/test/memoizable_test.rb
parent105093f90728f81268367bd52581fccfa165f170 (diff)
downloadrails-a8057669ff6ba11e228fc73eef7390b826d0de25.tar.gz
rails-a8057669ff6ba11e228fc73eef7390b826d0de25.tar.bz2
rails-a8057669ff6ba11e228fc73eef7390b826d0de25.zip
Fixed memoize with punctuation and freezing memoized methods with arguments
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activesupport/test/memoizable_test.rb')
-rw-r--r--activesupport/test/memoizable_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activesupport/test/memoizable_test.rb b/activesupport/test/memoizable_test.rb
index cd84dcda53..01631dc5e1 100644
--- a/activesupport/test/memoizable_test.rb
+++ b/activesupport/test/memoizable_test.rb
@@ -16,6 +16,16 @@ uses_mocha 'Memoizable' do
"Josh"
end
+ def name?
+ true
+ end
+ memoize :name?
+
+ def update(name)
+ "Joshua"
+ end
+ memoize :update
+
def age
@age_calls += 1
nil
@@ -88,6 +98,10 @@ uses_mocha 'Memoizable' do
assert_equal 1, @person.name_calls
end
+ def test_memoization_with_punctuation
+ assert_equal true, @person.name?
+ end
+
def test_memoization_with_nil_value
assert_equal nil, @person.age
assert_equal 1, @person.age_calls
@@ -114,6 +128,7 @@ uses_mocha 'Memoizable' do
def test_memoized_is_not_affected_by_freeze
@person.freeze
assert_equal "Josh", @person.name
+ assert_equal "Joshua", @person.update("Joshua")
end
def test_memoization_with_args