Sha256: 0b0bba6c04bf016394028b28a4f8fbf296f47bb24d061ed765387f02e69ee6af
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
require 'minitest_helper' describe Caching do class Cachable extend Caching cache :slow_method, :other_slow_method def initialize @slow_method = 0 @other_slow_method = 0 @fast_method = 0 end def slow_method @slow_method += 1 end def other_slow_method @other_slow_method += 1 end def fast_method @fast_method += 1 end end it 'Cache methods' do object = Cachable.new 3.times { object.slow_method.must_equal 1 } 3.times { object.other_slow_method.must_equal 1 } object.fast_method.must_equal 1 object.fast_method.must_equal 2 end it 'Clear cache for all methods' do object = Cachable.new 3.times { object.slow_method.must_equal 1 } 3.times { object.other_slow_method.must_equal 1 } object.clear_cache object.slow_method.must_equal 2 object.other_slow_method.must_equal 2 end it 'Clear cache for specific method' do object = Cachable.new 3.times { object.slow_method.must_equal 1 } 3.times { object.other_slow_method.must_equal 1 } object.clear_cache :slow_method object.slow_method.must_equal 2 object.other_slow_method.must_equal 1 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
caching-0.0.1 | spec/caching_spec.rb |