From 62eb1e8f29857a3963bbe1c484656eeaa007f063 Mon Sep 17 00:00:00 2001 From: Frederick Cheung Date: Fri, 24 Apr 2015 14:31:08 +0100 Subject: [PATCH 1/2] Simplify configuration with an actual cache store --- .../cache/dalli_elasticache_store.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/active_support/cache/dalli_elasticache_store.rb diff --git a/lib/active_support/cache/dalli_elasticache_store.rb b/lib/active_support/cache/dalli_elasticache_store.rb new file mode 100644 index 0000000..a78f5bc --- /dev/null +++ b/lib/active_support/cache/dalli_elasticache_store.rb @@ -0,0 +1,15 @@ +require 'dalli-elasticache' +require 'active_support/cache/dalli_store' + +module ActiveSupport + module Cache + class DalliElasticacheStore < DalliStore + def initialize(*endpoint_and_options) + endpoint, *options = endpoint_and_options + elasticache = Dalli::ElastiCache.new(endpoint) + super(elasticache.servers, options) + end + end + end +end + From e253044cf989f93fdb0923efea60e87ecf3d1c6d Mon Sep 17 00:00:00 2001 From: Justin Wilson Date: Tue, 24 Oct 2017 19:31:04 -0400 Subject: [PATCH 2/2] Add spec coverage for ActiveSupport extension --- spec/dalli_elasticache_store_spec.rb | 15 +++++++++++++++ spec/elasticache_spec.rb | 3 +++ spec/spec_helper.rb | 1 + 3 files changed, 19 insertions(+) create mode 100644 spec/dalli_elasticache_store_spec.rb diff --git a/spec/dalli_elasticache_store_spec.rb b/spec/dalli_elasticache_store_spec.rb new file mode 100644 index 0000000..cef6699 --- /dev/null +++ b/spec/dalli_elasticache_store_spec.rb @@ -0,0 +1,15 @@ +require_relative 'spec_helper' + +describe 'ActiveSupport::Cache::DalliElasticacheStore' do + + describe '#new' do + it 'responds to #new' do + ActiveSupport::Cache::DalliElasticacheStore.respond_to?(:new).should == true + end + + it 'inherits from DalliStore' do + ActiveSupport::Cache::DalliElasticacheStore.ancestors.include?(ActiveSupport::Cache::DalliStore).should == true + end + end + +end diff --git a/spec/elasticache_spec.rb b/spec/elasticache_spec.rb index 9234df3..628403d 100644 --- a/spec/elasticache_spec.rb +++ b/spec/elasticache_spec.rb @@ -33,6 +33,9 @@ end describe '#version' do + it 'has constant defined' do + defined?(Dalli::ElastiCache::VERSION).should == 'constant' + end end describe '#engine_version' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d9ea722..16e5a9c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,7 @@ require "bundler/setup" require "dalli/elasticache" +require "active_support/cache/dalli_elasticache_store" RSpec.configure do |config| config.expect_with :rspec do |c|