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 + 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|