spec/cachetastic/adapters/base_spec.rb in cachetastic-3.1.0 vs spec/cachetastic/adapters/base_spec.rb in cachetastic-3.2.0
- old
+ new
@@ -97,10 +97,11 @@
describe "#{adapter} (Common)" do
before(:each) do
configatron.cachetastic.defaults.adapter = "Cachetastic::Adapters::#{adapter}".constantize
CarCache.clear_adapter!
+ CarCache.expire_all
CarCache.set(:vw, 'Rabbit')
end
after(:each) do
CarCache.expire_all
@@ -151,16 +152,18 @@
CarCache.get(:bmw).should be_nil
CarCache.set(:bmw, 'Beamer!')
CarCache.get(:bmw).should_not be_nil
end
- it 'should set an object into the cache with an expiry' do
- CarCache.get(:bmw).should be_nil
- CarCache.set(:bmw, 'Beamer!', 1)
- CarCache.get(:bmw).should_not be_nil
- sleep(2)
- CarCache.get(:bmw).should be_nil
+ unless adapter == "Memcached"
+ it 'should set an object into the cache with an expiry' do
+ CarCache.get(:bmw).should be_nil
+ CarCache.set(:bmw, 'Beamer!', 1)
+ CarCache.get(:bmw).should_not be_nil
+ Timecop.travel(1.hour.from_now)
+ CarCache.get(:bmw).should be_nil
+ end
end
end
describe 'delete' do
@@ -186,10 +189,10 @@
end
describe 'retry' do
it 'should retry if there is an exception' do
- CarCache.should_receive(:clear_adapter!).twice
+ CarCache.instance.should_receive(:clear_adapter!).twice
lambda {
CarCache.get(:audi) do
raise Cachetastic::BlockError.new
end
}.should raise_error(Cachetastic::BlockError)