Sha256: 23db07d003e8f375e8205cb68c52b6d41cd1cf8883a3a6b19a6d10bc6cf3700f

Contents?: true

Size: 691 Bytes

Versions: 2

Compression:

Stored size: 691 Bytes

Contents

require 'test_helper'



class CachingTest < ActiveSupport::TestCase
  include Apotomo::TestCaseMethods::TestController
  
  class CheeseWidget < Apotomo::Widget
    cache :holes
    
    @@holes = 0
    cattr_accessor :holes
    
    
    #def self.reset!
    #  @@counter = 0
    #end
    
    def increment!
      self.class.holes += 1
    end
    
    def holes
      render :text => increment!
    end 
  end
  
  context "A caching widget" do
    setup do
      @cheese = CheeseWidget.new(parent_controller, 'cheese', :holes)
    end
    
    should "invoke the cached state only once" do
      assert_equal "1", @cheese.invoke
      assert_equal "1", @cheese.invoke
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
apotomo-1.0.5 test/rails/caching_test.rb
apotomo-1.0.4 test/rails/caching_test.rb