Sha256: a0629156af22d03687106afb855e34f655a1e2614f79b46d9f784a0bdf3b65d1

Contents?: true

Size: 863 Bytes

Versions: 27

Compression:

Stored size: 863 Bytes

Contents

require 'spec_helper'

describe 'Gris::Caching' do
  let(:id) { SecureRandom.random_number(500) }

  it 'uses the cache for cached_find' do
    foo = CachingHelper.cached_find(id)
    expect(foo.id).to eq(id)
    allow(Gris.cache).to receive(:fetch).and_return('cached-result')
    expect(CachingHelper.cached_find(id)).to eq('cached-result')
  end

  it 'expires cache for a given id' do
    allow(Gris.cache).to receive(:delete).with("cache_key_helper/#{id}")
    CachingHelper.expire_cache_for(id)
    expect(Gris.cache).to have_received(:delete).with("cache_key_helper/#{id}")
  end

  it 'expires cache for a given instance' do
    allow(Gris.cache).to receive(:delete).with("cache_key_helper/#{id}")
    instance = CachingHelper.new(id: id)
    instance.expire_cache
    expect(Gris.cache).to have_received(:delete).with("cache_key_helper/#{id}")
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
gris-0.6.8 spec/caching_spec.rb
gris-0.6.7 spec/caching_spec.rb
gris-0.6.6 spec/caching_spec.rb
gris-0.6.5 spec/caching_spec.rb
gris-0.6.2 spec/caching_spec.rb
gris-0.6.1 spec/caching_spec.rb
gris-0.6.0 spec/caching_spec.rb
gris-0.5.9 spec/caching_spec.rb
gris-0.5.8 spec/caching_spec.rb
gris-0.5.7 spec/caching_spec.rb
gris-0.5.6 spec/caching_spec.rb
gris-0.5.5 spec/caching_spec.rb
gris-0.5.4 spec/caching_spec.rb
gris-0.5.3 spec/caching_spec.rb
gris-0.5.2 spec/caching_spec.rb
gris-0.5.1 spec/caching_spec.rb
gris-0.5.0 spec/caching_spec.rb
gris-0.4.9 spec/caching_spec.rb
gris-0.4.8 spec/caching_spec.rb
gris-0.4.7 spec/caching_spec.rb