Sha256: 9c09acc820f082f3abe941fd5c406754f558686e39e366b8741ae45984e9c292

Contents?: true

Size: 1.54 KB

Versions: 12

Compression:

Stored size: 1.54 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'

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
roda-2.29.0 spec/plugin/not_allowed_spec.rb
roda-2.28.0 spec/plugin/not_allowed_spec.rb
roda-2.27.0 spec/plugin/not_allowed_spec.rb
roda-2.26.0 spec/plugin/not_allowed_spec.rb
roda-2.25.0 spec/plugin/not_allowed_spec.rb
roda-2.24.0 spec/plugin/not_allowed_spec.rb
roda-2.23.0 spec/plugin/not_allowed_spec.rb
roda-2.22.0 spec/plugin/not_allowed_spec.rb
roda-2.21.0 spec/plugin/not_allowed_spec.rb
roda-2.20.0 spec/plugin/not_allowed_spec.rb
roda-2.19.0 spec/plugin/not_allowed_spec.rb
roda-2.18.0 spec/plugin/not_allowed_spec.rb