Sha256: ec03f8ad8d5efd59244d9f1f919c483790b520bfe98072d520ed7512b750471a

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

require 'test_helper'
require 'redis-kit/cache'

class CachedClass
  include RedisKit::Cache::Helper
  cache_timeout 600
  cache_namespace "foo"

  def self.run
    one = cached( "bar", 10 ) do
      "one"
    end
    two = cached( "biz" ) do
      "two"
    end
    one + two
  end

  def run
    one = cached( "baz", 10 ) do
      "one"
    end
    two = cached( "bix" ) do
      "two"
    end
    one + two
  end
end

describe RedisKit::Cache::Helper do
  before do
    RedisKit.redis = RedisKit.new_redis( good_config_path, "test_mock" )
  end

  it "provides helpers" do
    CachedClass.run.must_equal "onetwo"
    RedisKit.redis.get( "foo:bar" ).must_equal "one"
    RedisKit.redis.ttl( "foo:bar" ).must_equal 10
    RedisKit.redis.get( "foo:biz" ).must_equal "two"
    RedisKit.redis.ttl( "foo:biz" ).must_equal 600

    CachedClass.new.run.must_equal "onetwo"
    RedisKit.redis.get( "foo:baz" ).must_equal "one"
    RedisKit.redis.ttl( "foo:baz" ).must_equal 10
    RedisKit.redis.get( "foo:bix" ).must_equal "two"
    RedisKit.redis.ttl( "foo:bix" ).must_equal 600
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redis-kit-0.1.0 test/redis-kit/cache/helper_test.rb
redis-kit-0.0.6 test/redis-kit/cache/helper_test.rb
redis-kit-0.0.5 test/redis-kit/cache/helper_test.rb
redis-kit-0.0.4 test/redis-kit/cache/helper_test.rb
redis-kit-0.0.3 test/redis-kit/cache/helper_test.rb