Sha256: 48af982f9de3e34c1f230585a6bb603fb0b514148fed524c90647a8f908aa716

Contents?: true

Size: 1.5 KB

Versions: 30

Compression:

Stored size: 1.5 KB

Contents

require_relative "../spec_helper"

describe "not_allowed plugin" do 
  it "skips the current block if pass is called" do
    app(:not_allowed) do |r|
      r.get '' do
        'a'
      end

      r.is "c" do
        r.get do
          "cg"
        end

        r.post do
          "cp"
        end

        "c"
      end

      r.on "q" do
        r.is do
          r.get do
            "q"
          end
        end
      end

      r.get do
        r.is 'b' do
          'b'
        end
        r.is(/(d)/) do |s|
          s
        end
        r.get(/(e)/) do |s|
          s
        end
      end
    end

    body.must_equal 'a'
    status('REQUEST_METHOD'=>'POST').must_equal 405
    header('Allow', 'REQUEST_METHOD'=>'POST').must_equal 'GET'

    body('/b').must_equal 'b'
    status('/b', 'REQUEST_METHOD'=>'POST').must_equal 404

    body('/d').must_equal 'd'
    status('/d', 'REQUEST_METHOD'=>'POST').must_equal 404

    body('/e').must_equal 'e'
    status('/e', 'REQUEST_METHOD'=>'POST').must_equal 404

    body('/q').must_equal 'q'
    status('/q', 'REQUEST_METHOD'=>'POST').must_equal 405

    body('/c').must_equal 'cg'
    body('/c').must_equal 'cg'
    body('/c', 'REQUEST_METHOD'=>'POST').must_equal 'cp'
    body('/c', 'REQUEST_METHOD'=>'PATCH').must_equal 'c'
    status('/c', 'REQUEST_METHOD'=>'PATCH').must_equal 405
    header('Allow', '/c', 'REQUEST_METHOD'=>'PATCH').must_equal 'GET, POST'

    @app.plugin :head
    header('Allow', '/c', 'REQUEST_METHOD'=>'PATCH').must_equal 'HEAD, GET, POST'
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
roda-3.28.0 spec/plugin/not_allowed_spec.rb
roda-3.27.0 spec/plugin/not_allowed_spec.rb
roda-3.26.0 spec/plugin/not_allowed_spec.rb
roda-3.25.0 spec/plugin/not_allowed_spec.rb
roda-3.24.0 spec/plugin/not_allowed_spec.rb
roda-3.23.0 spec/plugin/not_allowed_spec.rb
roda-3.22.0 spec/plugin/not_allowed_spec.rb
roda-3.21.0 spec/plugin/not_allowed_spec.rb
roda-3.20.0 spec/plugin/not_allowed_spec.rb
roda-3.19.0 spec/plugin/not_allowed_spec.rb
roda-3.18.0 spec/plugin/not_allowed_spec.rb
roda-3.17.0 spec/plugin/not_allowed_spec.rb
roda-3.16.0 spec/plugin/not_allowed_spec.rb
roda-3.15.0 spec/plugin/not_allowed_spec.rb
roda-3.14.1 spec/plugin/not_allowed_spec.rb
roda-3.14.0 spec/plugin/not_allowed_spec.rb
roda-3.13.0 spec/plugin/not_allowed_spec.rb
roda-3.12.0 spec/plugin/not_allowed_spec.rb
roda-3.11.0 spec/plugin/not_allowed_spec.rb
roda-3.10.0 spec/plugin/not_allowed_spec.rb