Sha256: 1d79af5f83d8f79eea3701ce73aca36e68b817b12527ae79c458355daa7cd930

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 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
  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

1 entries across 1 versions & 1 rubygems

Version Path
routemaster-drain-2.5.1 spec/routemaster/jobs/cache_and_sweep_spec.rb