Sha256: 1f58ad6ea5c3475630f946d4c1e7838eff83aa271703ee345a3179813b261396

Contents?: true

Size: 1.05 KB

Versions: 18

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Frodo::Concerns::Caching do
  describe '.without_caching' do
    let(:options) { double('Options') }
    let(:klass) do
      context = self
      Class.new {
        include Frodo::Concerns::Base
        include context.described_class
      }
    end
    let(:client) { klass.new }
    subject { client }

    before do
      expect(client).to receive(:options).and_return(options).twice
    end

    it 'runs the block with caching disabled' do
      expect(options).to receive(:[]=).with(:use_cache, false)
      expect(options).to receive(:delete).with(:use_cache)
      expect { |b| client.without_caching(&b) }.to yield_control
    end

    context 'when an exception is raised' do
      it 'ensures the :use_cache is deleted' do
        expect(options).to receive(:[]=).with(:use_cache, false)
        expect(options).to receive(:delete).with(:use_cache)
        expect {
          client.without_caching do
            raise 'Foo'
          end
        }.to raise_error 'Foo'
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
frodo-0.12.8 spec/frodo/concerns/caching_spec.rb
frodo-0.12.7 spec/frodo/concerns/caching_spec.rb
frodo-0.12.6 spec/frodo/concerns/caching_spec.rb
frodo-0.12.5 spec/frodo/concerns/caching_spec.rb
frodo-0.12.4 spec/frodo/concerns/caching_spec.rb
frodo-0.12.2 spec/frodo/concerns/caching_spec.rb
frodo-0.12.1 spec/frodo/concerns/caching_spec.rb
frodo-0.12.0 spec/frodo/concerns/caching_spec.rb
frodo-0.11.0 spec/frodo/concerns/caching_spec.rb
frodo-0.10.8 spec/frodo/concerns/caching_spec.rb
frodo-0.10.7 spec/frodo/concerns/caching_spec.rb
frodo-0.10.6 spec/frodo/concerns/caching_spec.rb
frodo-0.10.5 spec/frodo/concerns/caching_spec.rb
frodo-0.10.4 spec/frodo/concerns/caching_spec.rb
frodo-0.10.3 spec/frodo/concerns/caching_spec.rb
frodo-0.10.2 spec/frodo/concerns/caching_spec.rb
frodo-0.10.1 spec/frodo/concerns/caching_spec.rb
frodo-0.10.0 spec/frodo/concerns/caching_spec.rb