Sha256: dc9e06c16e9e06a66626bedf785a3d5840bee40149ab0cb09cd42f2ace975964

Contents?: true

Size: 1.22 KB

Versions: 24

Compression:

Stored size: 1.22 KB

Contents

require 'routemaster/jobs/cache_and_sweep'
require 'routemaster/dirty/map'
require 'spec_helper'

RSpec.describe Routemaster::Jobs::CacheAndSweep do
  let(:url) { 'https://example.com/foo' }

  subject { described_class.new }

  context 'when there is an ResourceNotFound error' do
    before do
      allow_any_instance_of(Routemaster::Cache)
        .to receive(:get)
        .and_raise(Routemaster::Errors::ResourceNotFound.new(""))
    end

    it 'does not bubble up the error' do
      expect { subject.perform(url) }.to_not raise_error
    end

    it 'sweeps the resource from the dirty map' do
      expect_any_instance_of(Routemaster::Dirty::Map)
        .to receive(:sweep_one)
        .with(url) { |&block| expect(block.call).to eq true }

      subject.perform(url)
    end

    it 'busts the cached version of the resource' do
      expect_any_instance_of(Routemaster::Cache)
        .to receive(:bust)
        .with(url)

      subject.perform(url)
    end
  end

  context 'when there is any other error' do
    before do
      expect_any_instance_of(Routemaster::Cache).to receive(:get).and_raise("boom")
    end

    it 'does bubble up the error' do
      expect { subject.perform('url') }.to raise_error("boom")
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
routemaster-drain-3.7.1 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.7.0 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.6.8 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.6.7 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.6.6 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.6.5 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.6.4 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.6.3 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.6.2 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.6.1 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.6.0 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.5.1 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.5.0 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.4.0 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.3.0 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.2.0 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.1.0 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.0.3 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.0.2 spec/routemaster/jobs/cache_and_sweep_spec.rb
routemaster-drain-3.0.1 spec/routemaster/jobs/cache_and_sweep_spec.rb