mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
* attempt to improve semantics for legibility * Attempt to improve legibility by simplifying * Make it more clear that we're calling procs/blocks here * Enable rubocop Style/BlockDelimiters cop * Prefer 'request' over 'req' abbreviation for legibility/clarity * Instances of Track named 'track' not 'tracker'
43 lines
943 B
Ruby
43 lines
943 B
Ruby
require 'active_support/cache'
|
|
require 'redis-activesupport'
|
|
require 'dalli'
|
|
require_relative '../spec_helper'
|
|
|
|
OfflineExamples = Minitest::SharedExamples.new do
|
|
it 'should write' do
|
|
@cache.write('cache-test-key', 'foobar', 1)
|
|
end
|
|
|
|
it 'should read' do
|
|
@cache.read('cache-test-key')
|
|
end
|
|
|
|
it 'should count' do
|
|
@cache.send(:do_count, 'rack::attack::cache-test-key', 1)
|
|
end
|
|
end
|
|
|
|
describe 'when Redis is offline' do
|
|
include OfflineExamples
|
|
|
|
before do
|
|
@cache = Rack::Attack::Cache.new
|
|
# Use presumably unused port for Redis client
|
|
@cache.store = ActiveSupport::Cache::RedisStore.new(:host => '127.0.0.1', :port => 3333)
|
|
end
|
|
end
|
|
|
|
describe 'when Memcached is offline' do
|
|
include OfflineExamples
|
|
|
|
before do
|
|
Dalli.logger.level = Logger::FATAL
|
|
|
|
@cache = Rack::Attack::Cache.new
|
|
@cache.store = Dalli::Client.new('127.0.0.1:22122')
|
|
end
|
|
|
|
after do
|
|
Dalli.logger.level = Logger::INFO
|
|
end
|
|
end
|