Sha256: 9083b395eddf1598db6f76baa30913a876a3ffe6a18d71d2592e835e9ef6c559

Contents?: true

Size: 1005 Bytes

Versions: 14

Compression:

Stored size: 1005 Bytes

Contents

require 'spec_helper'
require 'spec/support/rack_test'
require 'spec/support/events'
require 'routemaster/middleware/root_post_only'

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

  describe '#call' do
    it 'passes for POST to root' do
      post '/'
      expect(last_response.status).to eq(501)
    end

    it '405s on non-POST' do
      get '/'
      expect(last_response.status).to eq(405)
    end

    it '404s on non-root path' do
      get '/why_not_even'
      expect(last_response.status).to eq(404)
    end

    context 'when mounted under another path' do
      let(:app) do
        Rack::Builder.new do
          map '/what' do
            use Routemaster::Middleware::RootPostOnly
            run ErrorRackApp.new
          end
        end
      end

      it 'passes for POST to mountpoint' do
        post '/what'
        expect(last_response.status).to eq(501)
      end
    end
  end
end




Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
routemaster-drain-2.4.4 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-2.4.3 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-2.4.2 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-2.4.1 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-2.4.0 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-2.3.0 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-2.2.2 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-2.0.0 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-1.1.0 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-1.0.5 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-1.0.4 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-1.0.3 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-1.0.2 spec/routemaster/middleware/root_post_only_spec.rb
routemaster-drain-1.0.1 spec/routemaster/middleware/root_post_only_spec.rb