Sha256: a682768f15917357cde6ba243deb5f673a14cc418e6be30547b6a1ff38305e09

Contents?: true

Size: 862 Bytes

Versions: 6

Compression:

Stored size: 862 Bytes

Contents

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

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

  let(:terminator) { ErrorRackApp.new }
  let(:app) { described_class.new(terminator, **options) }
  let(:resque) { double 'resque', enqueue_to: nil }
  let(:cache) { double 'cache', bust: nil }
  let(:options) {{ cache: cache, resque: resque }}
  
  let(:perform) do
    post '/whatever', '', 'routemaster.dirty' => payload
  end

  describe '#call' do
    let(:payload) { ['https://example.com/1'] }
    
    it 'busts the cache' do
      expect(cache).to receive(:bust).with(payload.first)
      perform
    end

    it 'queues a fetch job' do
      expect(resque).to receive(:enqueue_to).with('routemaster', anything, 'https://example.com/1')
      perform
    end
  end
end



Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
routemaster-drain-1.0.5 spec/routemaster/middleware/cache_spec.rb
routemaster-drain-1.0.4 spec/routemaster/middleware/cache_spec.rb
routemaster-drain-1.0.3 spec/routemaster/middleware/cache_spec.rb
routemaster-drain-1.0.2 spec/routemaster/middleware/cache_spec.rb
routemaster-drain-1.0.1 spec/routemaster/middleware/cache_spec.rb
routemaster-drain-1.0.0 spec/routemaster/middleware/cache_spec.rb