Sha256: 9b20f482a60e173e14d585f77e5f114713a18fc782dfe5051c0cbce563e9b83c

Contents?: true

Size: 1017 Bytes

Versions: 2

Compression:

Stored size: 1017 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + "/../test_helper")


class ApotomoCachingTest < Test::Unit::TestCase
  include Apotomo::UnitTestCase
  
  def setup
    super
    @controller.session= {}
    @cc = CachingCell.new('caching_cell', :start)
    @cc.controller = @controller
  end
  
  
  def test_caching_with_instance_version_proc
    unless ActionController::Base.cache_configured?
      throw Exception.new "cache_configured? returned false. You may enable caching in your config/environments/test.rb to make this test pass."
      return
    end
    c1 = @cc.invoke
    c2 = @cc.invoke
    assert_equal c1, c2
    
    @cc.dirty!
    
    c3 = @cc.invoke
    assert c2 != c3
  end
  
end


class CachingCell < Apotomo::StatefulWidget
  
  cache :cached_state
  
  transition :in => :cached_state
  
  
  def start
    jump_to_state :cached_state
  end
  
  def cached_state
    @counter ||= 0
    @counter += 1
    "#{@counter}"
    
  end
  
  def not_cached_state
    "i'm really static"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
apotomo-0.1.2 test/unit/test_caching.rb
apotomo-0.1.1 test/unit/test_caching.rb