Sha256: bbc8fd50852838c62e9092a6c3869086d6b94e1b362d7e3099223947e6250643

Contents?: true

Size: 882 Bytes

Versions: 41

Compression:

Stored size: 882 Bytes

Contents

require 'spec_helper'
require 'spec/support/rack_test'
require 'spec/support/uses_redis'
require 'spec/support/uses_dotenv'
require 'spec/support/events'
require 'routemaster/drain/basic'
require 'json'

describe Routemaster::Drain::Basic do
  uses_dotenv
  uses_redis

  let(:app) { described_class.new }
  let(:listener) { double 'listener' }
  
  before { app.subscribe(listener, prefix: true) }

  let(:path)    { '/' }
  let(:payload) { [1,2,3,1].map { |idx| make_event(idx) }.to_json }
  let(:environment) {{ 'CONTENT_TYPE' => 'application/json' }}
  let(:perform) { post path, payload, environment }

  before { authorize 'd3m0', 'x' }

  it 'succeeds' do
    perform
    expect(last_response.status).to eq(204)
  end

  it 'emits events' do
    expect(listener).to receive(:on_events_received) do |payload|
      expect(payload.size).to eq(4)
    end
    perform
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

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