Sha256: 0aec920c20fd182e58c2cc4aabb0d7dbad4d0041e9d47b82bb69f16463be3985

Contents?: true

Size: 1.31 KB

Versions: 26

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'
require 'spec/support/rack_test'
require 'spec/support/events'
require 'routemaster/middleware/siphon'
require 'json'

describe Routemaster::Middleware::Siphon do
  let(:terminator) { ErrorRackApp.new }
  let(:app) { described_class.new(terminator, options) }

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

  describe '#call' do

    let(:options) { { filter:filter } }
    let(:payload) { [ make_event(1), make_event(1).merge({'topic' => 'notstuff'})] }

    context "if no siphon is defined" do
      let(:options) { {} }

      it "passes all to the terminator"  do
        perform
        expect(terminator.last_env['routemaster.payload']).to eq payload
      end
    end

    context "if a 'stuff' siphon is defined" do
      let(:siphon_double) { double(new: siphon_instance) }
      let(:siphon_instance) { double(call: nil) }
      let(:options) { { siphon_events: { 'stuff' => siphon_double } } } 

      it "calls the siphon with the event" do
        perform
        expect(siphon_double).to have_received(:new).with(payload[0])
        expect(siphon_instance).to have_received(:call)
      end

      it "passes 'notstuff' to the terminator"  do
        perform
        expect(terminator.last_env['routemaster.payload']).to eq [payload[1]]
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

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