Sha256: 24c94ac83b1bde076eab6cb8a6bdccfa22f463ddc0bba98fb068b8c0810c08fc

Contents?: true

Size: 570 Bytes

Versions: 1

Compression:

Stored size: 570 Bytes

Contents

require "test_helper"

class CacheKeeper::CachedMethodTest < ActiveSupport::TestCase
  test "#call caches the result of the original method" do
    recording = Recording.create(number: 5)
    cached_method = manager.handle(Recording, :another_method, expires_in: 1.hour)
    manager.activate_if_handling(Recording, :another_method)

    result = cached_method.call(recording)

    assert_equal 5, result
    assert cache_has_key? "CacheKeeper/recordings/#{recording.id}/another_method"
  end

  private

  def manager
    @manager ||= CacheKeeper::Manager.new
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cache_keeper-0.4.0 test/models/cached_method_test.rb