Sha256: 4f0ea6ac96cbbc491f708e9815c0b3cebe1fbfa6e18211b4df9b9892a3d49bc8

Contents?: true

Size: 944 Bytes

Versions: 5

Compression:

Stored size: 944 Bytes

Contents

require 'spec_helper'
require 'spec/support/rack_test'
require 'routemaster/middleware/cache'
require 'routemaster/event_index'

RSpec.describe Routemaster::Middleware::Cache do
  # busts the cache for each dirty url

  let(:terminator) { ErrorRackApp.new }
  let(:app) { described_class.new(terminator, **options) }
  let(:client) { Routemaster::Jobs::Client.new }
  let(:cache) { instance_double(Routemaster::Cache, bust: nil, invalidate: nil) }
  let(:options) {{ cache: cache, client: client }}

  let(:perform) do
    post '/whatever', '', 'routemaster.dirty' => payload
  end

  describe '#call' do
    let(:payload) { ['https://example.com/1'] }

    it 'increments the event_index' do
      expect(cache).to receive(:invalidate)
      perform
    end

    it 'queues a fetch job' do
      expect(client).to receive(:enqueue).with('routemaster', Routemaster::Jobs::CacheAndSweep, 'https://example.com/1')
      perform
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
routemaster-drain-2.4.4 spec/routemaster/middleware/cache_spec.rb
routemaster-drain-2.4.3 spec/routemaster/middleware/cache_spec.rb
routemaster-drain-2.4.2 spec/routemaster/middleware/cache_spec.rb
routemaster-drain-2.4.1 spec/routemaster/middleware/cache_spec.rb
routemaster-drain-2.4.0 spec/routemaster/middleware/cache_spec.rb