public
Description: To provide a cleaner, more modular, heavier spec'd, more blackbox'd cache engine for Merb
Clone URL: git://github.com/benschwarz/merb-cache.git
merb-cache / spec / merb-cache / controller / support / cache_proxy_spec.rb
100644 98 lines (82 sloc) 3.406 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
require File.dirname(__FILE__) + '/../../../spec_helper'
 
describe "Merb::Controller cache proxy" do
  
  describe Merb::Controller do
    describe "class methods" do
      # cache.page # should use a PageCacheProxy
      # cache.action # shoudl use an ActionCacheProxy
    end
    
    describe "instance methods" do
      # cache(:store) should instantiate a proxy if one doesn't exist
      
      describe "force_cache_update!" do
        # @controller.cache.force_update!
      end
      
      describe "expire_cache!" do
        # @controller.cache.expire!(:action, :show, {:id => blah}, @controller.request.env)
        # @controller.cache.expire!
        # @controller.cache.expire!(:page, :index)
        # @controller.cache.fragment.expire!(:this => is, :my => :key)
      end
 
      describe "refresh_cache!" do
        # @controller.cache.refresh!(:action, :show, :id => blah)
        # @controller.cache(:my_store).refresh!(:page, :index)
      end
 
      describe "fragment_cache" do
        # should instantiate a FragmentCacheProxy
        # @controller.cache.fragment.write
        # @controller.cache(:my_frag_cache).fragment.read(key)
      end
      
    end
  end
   
  describe Merb::Controller::AbstractCacheProxy do
    class AProxy < Merb::Controller::AbstractCacheProxy; end
    class AController < Merb::Controller; end
    before(:each) do
      @controller = AController.new({})
      @proxy = AProxy.new
    end
 
    describe "controller" do
      it{@proxy.should respond_to(:controller)}
      
      it "should raise an error if there is no controller supplied"
      it "should return the controller"
      it "should attach itself to the controller instance"
    end
    
    describe "base_key" do
      it{@proxy.should respond_to(:base_key)}
      it "should allow you to set the base_key via an option"
      it "should take the base_key as a proc or value"
      it "should pass the controller to the proc"
      it "shoudl be set with a directory object"
      it "shoudl be set with a string"
      it "should be set with an array"
      it "should evaluate to a string"
      it "should evaluate to a string the return of the block"
    end
    
    describe "param_key" do
      it{@proxy.should respond_to(:param_key)}
      it "shoudl allow you to set the param_key via an option"
      it "should allow the param_key to be set with a proc or value"
      it "should take the param_key as a proc or value"
      it "should pass the controller to the proc"
      it "shoudl be set with a directory object"
      it "shoudl be set with a string"
      it "should be set with an array"
      it "should evaluate to a string"
      it "should evaluate to a string the return of the block"
    end
    
    describe "id_key" do
      it{@proxy.should respond_to(:id_key)}
      it "shoudl allow you to set the id_key via an option"
      it "should allow the id_key to be set with a proc or value"
      it "should take the id_key as a proc or value"
      it "should pass the controller to the proc"
      it "shoudl be set with a directory object"
      it "shoudl be set with a string"
      it "should be set with an array"
      it "should evaluate to a string"
      it "should evaluate to a string the return of the block"
    end
    
    describe "retain_cache!" do
      # @controller.cache.retain_cache!
    end
  end
  
end