Sha256: 3475cd34d9356fcf6c69fe6933dde30c57e6bcde696b31269554bbc5857820a7

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

require 'spec_helper'

describe WhatsUpDoc::Middleware do
  it 'should have a version number' do
    WhatsUpDoc::VERSION.should_not be_nil
  end

  let(:app){->(env) { [200, env, "app"]}}
  let(:middleware){WhatsUpDoc::Middleware.new(app, path: '/up')}

  context 'when GET /up is called' do
    let(:env){Rack::MockRequest.env_for('https://www.example.com/up', {})}

    it 'responds to up with 200' do
      code, headers, body = middleware.call(env)

      expect(code).to eq(200)
      expect(headers).to eq('Content-Type' => 'text/plain')
      expect(body).to eq([''])
    end
  end

  context 'when another path is called' do
    let(:env){Rack::MockRequest.env_for('https://www.example.com/somewhere-else', {})}

    it 'delegates to the next app in the chain' do
      expect(app).to receive(:call).with(env)

      middleware.call(env)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whats_up_doc-0.0.2 spec/whats_up_doc_spec.rb