Sha256: f76efb6ac6d4eabaeebcc350d427394a8e35b86b4dd46412032d202389fe1767
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
require 'spec_helper' describe MethodCacheable do let(:user) { User.new } before(:each) do @uniq ||= 0 @uniq += 1 end describe '' do describe 'calling a cached method' do describe 'fetch' do it 'should return the result of the normal method' do user.cache.foo(@uniq).should == user.foo(@uniq) end it 'should bypass the normal method if the cache is written' do user.cache(:write).foo(@uniq) user.should_not_receive(:foo) user.cache(:fetch).foo(@uniq) end it 'should bypass the normal method if the cache has been fetched before' do user.cache(:fetch).foo(@uniq) user.should_not_receive(:foo) user.cache(:fetch).foo(@uniq) end it 'should call the normal method if the cache has been not fetched before' do user.should_receive(:foo) user.cache(:fetch).foo(@uniq) end it 'should call the normal method if the cache has been not fetched before' do user.should_receive(:foo) user.cache.foo(@uniq) end end describe 'read' do it 'read should return nil if cache has not been set yet' do user.cache(:read).foo(@uniq).should == nil end it 'read should return value if cache has been set' do result = user.cache.foo(@uniq) user.cache(:read).foo(@uniq).should == result end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
method_cacheable-0.1.0 | spec/method_cacheable_spec.rb |
method_cacheable-0.0.4 | spec/method_cacheable_spec.rb |