public
Fork of defunkt/cache_fu
Description: Everyone's favorite memcached plugin for ActiveRecord.
Homepage: http://errtheblog.com
Clone URL: git://github.com/technoweenie/cache_fu.git
defunkt (author)
Tue Jan 22 16:27:07 -0800 2008
cache_fu / test / disabled_test.rb
100644 41 lines (33 sloc) 1.269 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require File.join(File.dirname(__FILE__), 'helper')
 
context "When the cache is disabled" do
  setup do
    @story = Story.new(:id => 1, :title => "acts_as_cached 2 released!")
    @story2 = Story.new(:id => 2, :title => "BDD is something you can use")
    $stories = { 1 => @story, 2 => @story2 }
 
    config = YAML.load_file('defaults/memcached.yml.default')
    config['test'] = config['development'].merge('disabled' => true, 'benchmarking' => false)
    ActsAsCached.config = config
    Story.send :acts_as_cached
  end
 
  specify "get_cache should call through to the finder" do
    Story.expects(:find).at_least_once.returns(@story2)
    @story2.get_cache.should.equal @story2
  end
 
  specify "expire_cache should return true" do
    $cache.expects(:delete).never
    @story2.expire_cache.should.equal true
  end
 
  specify "reset_cache should return the object" do
    $cache.expects(:set).never
    Story.expects(:find).at_least_once.returns(@story2)
    @story2.reset_cache.should.equal @story2
  end
  
  specify "set_cache should just return the object" do
    $cache.expects(:set).never
    @story2.set_cache.should.equal @story2
  end
 
  specify "cached? should return false" do
    $cache.expects(:get).never
    @story2.should.not.be.cached
  end
end