test/memoist_test.rb in memoist-0.14.0 vs test/memoist_test.rb in memoist-0.15.0
- old
+ new
@@ -249,23 +249,22 @@
def test_flush_cache
assert_equal 1, @calculator.counter
assert @calculator.instance_variable_get(:@_memoized_counter)
@calculator.flush_cache(:counter)
- assert_nil @calculator.instance_variable_get(:@_memoized_counter)
- assert !@calculator.instance_variable_defined?(:@_memoized_counter)
+ assert_equal false, @calculator.instance_variable_defined?(:@_memoized_counter)
assert_equal 2, @calculator.counter
end
def test_unmemoize_all
assert_equal 1, @calculator.counter
+ assert_equal true, @calculator.instance_variable_defined?(:@_memoized_counter)
assert @calculator.instance_variable_get(:@_memoized_counter)
@calculator.unmemoize_all
- assert_nil @calculator.instance_variable_get(:@_memoized_counter)
- assert !@calculator.instance_variable_defined?(:@_memoized_counter)
+ assert_equal false, @calculator.instance_variable_defined?(:@_memoized_counter)
assert_equal 2, @calculator.counter
end
def test_all_memoized_structs
@@ -299,25 +298,25 @@
assert_equal "Josh", teacher.instance_variable_get(:@_memoized_name)
assert_equal "very_senior", teacher.seniority
assert_equal "very_senior", teacher.instance_variable_get(:@_memoized_seniority)
teacher.unmemoize_all
- assert_nil teacher.instance_variable_get(:@_memoized_name)
- assert_nil teacher.instance_variable_get(:@_memoized_seniority)
+ assert_equal false, teacher.instance_variable_defined?(:@_memoized_name)
+ assert_equal false, teacher.instance_variable_defined?(:@_memoized_seniority)
student = Student.new
assert_equal "Student Josh", student.name
assert_equal "Student Josh", student.instance_variable_get(:@_memoized_student_name)
- assert_nil student.instance_variable_get(:@_memoized_seniority)
+ assert_equal false, student.instance_variable_defined?(:@_memoized_seniority)
student.unmemoize_all
- assert_nil student.instance_variable_get(:@_memoized_student_name)
+ assert_equal false, @calculator.instance_variable_defined?(:@_memoized_student_name)
end
def test_memoize_all
@calculator.memoize_all
- assert @calculator.instance_variable_defined?(:@_memoized_counter)
+ assert_equal true, @calculator.instance_variable_defined?(:@_memoized_counter)
end
def test_memoize_all_subclasses
# Person memoize :age, :is_developer?, :memoize_protected_test, :name, :name?, :sleep, :update, :update_attributes
# Student < Person memoize :name, :identifier => :student
@@ -332,10 +331,10 @@
student = Student.new
student.memoize_all
assert_equal "Student Josh", student.instance_variable_get(:@_memoized_student_name)
assert_equal "Student Josh", student.name
- assert_nil student.instance_variable_get(:@_memoized_seniority)
+ assert_equal false, student.instance_variable_defined?(:@_memoized_seniority)
end
def test_memoization_cache_is_different_for_each_instance
assert_equal 1, @calculator.counter
assert_equal 2, @calculator.counter(:reload)