Sha256: 85e81555beed7ab799ef1532f6e5c5777d49278b110e50db9347008254efde15
Contents?: true
Size: 850 Bytes
Versions: 38
Compression:
Stored size: 850 Bytes
Contents
# frozen_string_literal: true require 'test_helper' require 'timecop' class RateLimitCacheTest < Minitest::Test def test_set_and_fresh cache = Prefab::RateLimitCache.new(5) cache.set('key') assert cache.fresh?('key') end def test_fresh_with_no_set cache = Prefab::RateLimitCache.new(5) refute cache.fresh?('key') end def test_get_after_expiration cache = Prefab::RateLimitCache.new(5) Timecop.freeze(Time.now - 6) do cache.set('key') assert cache.fresh?('key') end refute cache.fresh?('key') # but the data is still there assert cache.data.get('key') end def test_prune cache = Prefab::RateLimitCache.new(5) Timecop.freeze(Time.now - 6) do cache.set('key') assert cache.fresh?('key') end cache.prune refute cache.fresh?('key') end end
Version data entries
38 entries across 38 versions & 1 rubygems