Sha256: c18e05c60e6e4bb3436be7819af5bebaf32c3bed5630ac3f5326ad8f377ef658

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 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.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.should == 'a'
    status('REQUEST_METHOD'=>'POST').should == 405
    header('Allow', 'REQUEST_METHOD'=>'POST').should == 'GET'

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

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

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

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

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
roda-cj-1.0.5 spec/plugin/not_allowed_spec.rb
roda-cj-1.0.4 spec/plugin/not_allowed_spec.rb
roda-cj-1.0.3 spec/plugin/not_allowed_spec.rb
roda-cj-1.0.2 spec/plugin/not_allowed_spec.rb
roda-cj-1.0.1 spec/plugin/not_allowed_spec.rb
roda-cj-1.0.0 spec/plugin/not_allowed_spec.rb
roda-1.0.0 spec/plugin/not_allowed_spec.rb