Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
tstone committed Jun 23, 2021
commit 1db3bb9aaec93c5a8beaf8e73774b12fc9f45203
4 changes: 3 additions & 1 deletion lib/atomic_cache/storage/dalli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def read(key, user_options={})
end

def set(key, value, user_options={})
@dalli_client.set(key, value, user_options[:ttl], user_options)
ttl = user_options[:ttl]
user_options.delete(:ttl)
@dalli_client.set(key, value, ttl, user_options)
end

end
Expand Down
15 changes: 11 additions & 4 deletions spec/atomic_cache/storage/dalli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@ def delete(key, user_options); end
let(:dalli_client) { FakeDalli.new }
subject { AtomicCache::Storage::Dalli.new(dalli_client) }

it 'delegates #set without options' do
expect(dalli_client).to receive(:set).with('key', 'value', {})
subject.set('key', 'value')
context '#set' do
it 'delegates #set without options' do
expect(dalli_client).to receive(:set).with('key', 'value', nil, {})
subject.set('key', 'value')
end

it 'delegates #set with TTL' do
expect(dalli_client).to receive(:set).with('key', 'value', 500, {})
subject.set('key', 'value', { ttl: 500 })
end
end

it 'delegates #read without options' do
expect(dalli_client).to receive(:read).with('key', {}).and_return('asdf')
expect(dalli_client).to receive(:get).with('key', {}).and_return('asdf')
subject.read('key')
end

Expand Down