Namespace
- MODULE MemoizableTest::Rates
- CLASS MemoizableTest::Calculator
- CLASS MemoizableTest::Company
- CLASS MemoizableTest::Person
Methods
- S
- T
-
- test_double_memoization,
- test_flush_cache,
- test_memoization,
- test_memoization_cache_is_different_for_each_instance,
- test_memoization_flush_with_punctuation,
- test_memoization_with_args,
- test_memoization_with_boolean_arg,
- test_memoization_with_nil_value,
- test_memoization_with_punctuation,
- test_memoize_all,
- test_memoized_is_not_affected_by_freeze,
- test_memoized_module_methods,
- test_object_memoization,
- test_object_memoized_module_methods,
- test_private_method_memoization,
- test_protected_method_memoization,
- test_reloadable,
- test_reloadable_with_args,
- test_unmemoize_all
Instance Public methods
setup()
Link
test_double_memoization()
Link
# File activesupport/test/memoizable_test.rb, line 257 def test_double_memoization assert_raise(RuntimeError) { Person.memoize :name } person = Person.new ActiveSupport::Deprecation.silence do person.extend ActiveSupport::Memoizable end assert_raise(RuntimeError) { person.memoize :name } company = Company.new ActiveSupport::Deprecation.silence do company.extend ActiveSupport::Memoizable end company.memoize :name assert_raise(RuntimeError) { company.memoize :name } end
test_flush_cache()
Link
# File activesupport/test/memoizable_test.rb, line 166 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
test_memoization()
Link
test_memoization_cache_is_different_for_each_instance()
Link
test_memoization_flush_with_punctuation()
Link
test_memoization_with_args()
Link
test_memoization_with_boolean_arg()
Link
test_memoization_with_nil_value()
Link
test_memoization_with_punctuation()
Link
test_memoize_all()
Link
test_memoized_is_not_affected_by_freeze()
Link
test_memoized_module_methods()
Link
# File activesupport/test/memoizable_test.rb, line 236 def test_memoized_module_methods assert_equal 1.025, @calculator.sales_tax(10) assert_equal 1, @calculator.sales_tax_calls assert_equal 1.025, @calculator.sales_tax(10) assert_equal 1, @calculator.sales_tax_calls assert_equal 2.5625, @calculator.sales_tax(25) assert_equal 2, @calculator.sales_tax_calls end
test_object_memoization()
Link
# File activesupport/test/memoizable_test.rb, line 222 def test_object_memoization [Company.new, Company.new, Company.new].each do |company| ActiveSupport::Deprecation.silence do company.extend ActiveSupport::Memoizable end company.memoize :name assert_equal "37signals", company.name assert_equal 1, company.name_calls assert_equal "37signals", company.name assert_equal 1, company.name_calls end end
test_object_memoized_module_methods()
Link
# File activesupport/test/memoizable_test.rb, line 245 def test_object_memoized_module_methods company = Company.new company.extend(Rates) assert_equal 1.025, company.sales_tax(10) assert_equal 1, company.sales_tax_calls assert_equal 1.025, company.sales_tax(10) assert_equal 1, company.sales_tax_calls assert_equal 2.5625, company.sales_tax(25) assert_equal 2, company.sales_tax_calls end
test_private_method_memoization()
Link
# File activesupport/test/memoizable_test.rb, line 280 def test_private_method_memoization person = Person.new assert_raise(NoMethodError) { person.is_developer? } assert_equal "Yes", person.send(:is_developer?) assert_equal 1, person.is_developer_calls assert_equal "Yes", person.send(:is_developer?) assert_equal 1, person.is_developer_calls end
test_protected_method_memoization()
Link
test_reloadable()
Link
test_reloadable_with_args()
Link
# File activesupport/test/memoizable_test.rb, line 208 def test_reloadable_with_args assert_equal 55, @calculator.fib(10) assert_equal 11, @calculator.fib_calls assert_equal 55, @calculator.fib(10, :reload) assert_equal 12, @calculator.fib_calls assert_equal 55, @calculator.fib(10, true) assert_equal 13, @calculator.fib_calls end
test_unmemoize_all()
Link
# File activesupport/test/memoizable_test.rb, line 176 def test_unmemoize_all assert_equal 1, @calculator.counter assert @calculator.instance_variable_get(:@_memoized_counter).any? @calculator.unmemoize_all assert @calculator.instance_variable_get(:@_memoized_counter).empty? assert_equal 2, @calculator.counter end