Only require redis stores when running their respective appraisal

This commit is contained in:
Gonzalo Rodriguez 2018-06-22 18:55:27 -03:00
parent bd2ade8977
commit a72bfb5fc7
No known key found for this signature in database
GPG key ID: 5DB8B81B049B8AB1
12 changed files with 159 additions and 94 deletions

View file

@ -37,3 +37,22 @@ appraise "connection_pool_dalli" do
gem "connection_pool", "~> 2.2"
gem "dalli", "~> 2.7"
end
appraise "active_support_redis_cache_store" do
gem "activesupport", "~> 5.2.0"
gem "redis", "~> 4.0"
end
appraise "active_support_redis_cache_store_pooled" do
gem "activesupport", "~> 5.2.0"
gem "connection_pool", "~> 2.2"
gem "redis", "~> 4.0"
end
appraise "redis_store" do
gem "redis-store", "~> 1.5"
end
appraise "active_support_redis_store" do
gem "redis-activesupport", "~> 5.0"
end

View file

@ -0,0 +1,8 @@
# This file was generated by Appraisal
source "https://rubygems.org"
gem "activesupport", "~> 5.2.0"
gem "redis", "~> 4.0"
gemspec path: "../"

View file

@ -0,0 +1,9 @@
# This file was generated by Appraisal
source "https://rubygems.org"
gem "activesupport", "~> 5.2.0"
gem "connection_pool", "~> 2.2"
gem "redis", "~> 4.0"
gemspec path: "../"

View file

@ -0,0 +1,7 @@
# This file was generated by Appraisal
source "https://rubygems.org"
gem "redis-activesupport", "~> 5.0"
gemspec path: "../"

View file

@ -0,0 +1,7 @@
# This file was generated by Appraisal
source "https://rubygems.org"
gem "redis-store", "~> 1.5"
gemspec path: "../"

View file

@ -48,5 +48,4 @@ Gem::Specification.new do |s|
# which rack-attack uses only for testing compatibility in test suite.
s.add_development_dependency 'actionpack', '>= 3.0.0'
s.add_development_dependency 'activesupport', '>= 3.0.0'
s.add_development_dependency 'redis-activesupport'
end

View file

@ -1,10 +1,9 @@
require_relative "../../spec_helper"
if defined?(::ConnectionPool)
if defined?(::ConnectionPool) && defined?(::Redis) && defined?(::ActiveSupport::Cache::RedisCacheStore)
require_relative "../../support/cache_store_helper"
require "timecop"
if ActiveSupport.version >= Gem::Version.new("5.2.0")
describe "ActiveSupport::Cache::RedisCacheStore (pooled) as a cache backend" do
before do
Rack::Attack.cache.store = ActiveSupport::Cache::RedisCacheStore.new(pool_size: 2)
@ -39,4 +38,3 @@ if defined?(::ConnectionPool)
end
end
end
end

View file

@ -1,9 +1,9 @@
require_relative "../../spec_helper"
require_relative "../../support/cache_store_helper"
if defined?(::Redis) && defined?(::ActiveSupport::Cache::RedisCacheStore)
require_relative "../../support/cache_store_helper"
require "timecop"
if ActiveSupport.version >= Gem::Version.new("5.2.0")
describe "ActiveSupport::Cache::RedisCacheStore as a cache backend" do
before do
Rack::Attack.cache.store = ActiveSupport::Cache::RedisCacheStore.new

View file

@ -1,7 +1,7 @@
require_relative "../../spec_helper"
require_relative "../../support/cache_store_helper"
require "redis-activesupport"
if defined?(::ActiveSupport::Cache::RedisStore)
require_relative "../../support/cache_store_helper"
require "timecop"
describe "ActiveSupport::Cache::RedisStore as a cache backend" do
@ -37,3 +37,4 @@ describe "ActiveSupport::Cache::RedisStore as a cache backend" do
assert_nil Rack::Attack.cache.store.read(key)
end
end
end

View file

@ -1,7 +1,7 @@
require_relative "../../spec_helper"
require_relative "../../support/cache_store_helper"
require "redis-store"
if defined?(::Redis::Store)
require "timecop"
describe "ActiveSupport::Cache::RedisStore as a cache backend" do
@ -37,3 +37,4 @@ describe "ActiveSupport::Cache::RedisStore as a cache backend" do
assert_nil Rack::Attack.cache.store.read(key)
end
end
end

View file

@ -1,5 +1,4 @@
require 'active_support/cache'
require 'redis-activesupport'
require_relative '../spec_helper'
OfflineExamples = Minitest::SharedExamples.new do
@ -16,6 +15,7 @@ OfflineExamples = Minitest::SharedExamples.new do
end
end
if defined?(::ActiveSupport::Cache::RedisStore)
describe 'when Redis is offline' do
include OfflineExamples
@ -25,6 +25,7 @@ describe 'when Redis is offline' do
@cache.store = ActiveSupport::Cache::RedisStore.new(:host => '127.0.0.1', :port => 3333)
end
end
end
if defined?(::Dalli)
describe 'when Memcached is offline' do

View file

@ -23,6 +23,21 @@ begin
rescue LoadError
end
begin
require "redis"
rescue LoadError
end
begin
require "redis-activesupport"
rescue LoadError
end
begin
require "redis-store"
rescue LoadError
end
class MiniTest::Spec
include Rack::Test::Methods