Sha256: 2811ecc7e225fbe93f52a9a14f1200e813bd803f77ddc87ad95828f99092e101

Contents?: true

Size: 1.44 KB

Versions: 16

Compression:

Stored size: 1.44 KB

Contents

require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))

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'
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
roda-2.17.0 spec/plugin/not_allowed_spec.rb
roda-2.16.0 spec/plugin/not_allowed_spec.rb
roda-2.15.0 spec/plugin/not_allowed_spec.rb
roda-2.14.0 spec/plugin/not_allowed_spec.rb
roda-2.13.0 spec/plugin/not_allowed_spec.rb
roda-2.12.0 spec/plugin/not_allowed_spec.rb
roda-2.11.0 spec/plugin/not_allowed_spec.rb
roda-2.10.0 spec/plugin/not_allowed_spec.rb
roda-2.9.0 spec/plugin/not_allowed_spec.rb
roda-2.8.0 spec/plugin/not_allowed_spec.rb
roda-2.7.0 spec/plugin/not_allowed_spec.rb
roda-2.6.0 spec/plugin/not_allowed_spec.rb
roda-2.5.1 spec/plugin/not_allowed_spec.rb
roda-2.5.0 spec/plugin/not_allowed_spec.rb
roda-2.4.0 spec/plugin/not_allowed_spec.rb
roda-2.3.0 spec/plugin/not_allowed_spec.rb