Sha256: 321716be5e6dbb04c5a505105fab613e6928de42e4041867eb915ea772ca2e51

Contents?: true

Size: 991 Bytes

Versions: 17

Compression:

Stored size: 991 Bytes

Contents

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

describe "middleware plugin" do 
  it "turns Roda app into middlware" do
    a2 = app(:bare) do
      plugin :middleware

      route do |r|
        r.is "a" do
          "a2"
        end
        r.post "b" do
          "b2"
        end
      end
    end

    a3 = app(:bare) do
      plugin :middleware

      route do |r|
        r.get "a" do
          "a3"
        end
        r.get "b" do
          "b3"
        end
      end
    end

    app(:bare) do
      use a3
      use a2

      route do |r|
        r.is "a" do
          "a1"
        end
        r.is "b" do
          "b1"
        end
      end
    end

    body('/a').should == 'a3'
    body('/b').should == 'b3'
    body('/a', 'REQUEST_METHOD'=>'POST').should == 'a2'
    body('/b', 'REQUEST_METHOD'=>'POST').should == 'b2'
    body('/a', 'REQUEST_METHOD'=>'PATCH').should == 'a2'
    body('/b', 'REQUEST_METHOD'=>'PATCH').should == 'b1'
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
roda-1.3.0 spec/plugin/middleware_spec.rb
roda-1.2.0 spec/plugin/middleware_spec.rb
roda-1.1.0 spec/plugin/middleware_spec.rb
roda-cj-1.0.5 spec/plugin/middleware_spec.rb
roda-cj-1.0.4 spec/plugin/middleware_spec.rb
roda-cj-1.0.3 spec/plugin/middleware_spec.rb
roda-cj-1.0.2 spec/plugin/middleware_spec.rb
roda-cj-1.0.1 spec/plugin/middleware_spec.rb
roda-cj-1.0.0 spec/plugin/middleware_spec.rb
roda-1.0.0 spec/plugin/middleware_spec.rb
roda-cj-0.9.6 spec/plugin/middleware_spec.rb
roda-cj-0.9.5 spec/plugin/middleware_spec.rb
roda-cj-0.9.4 spec/plugin/middleware_spec.rb
roda-cj-0.9.3 spec/plugin/middleware_spec.rb
roda-cj-0.9.2 spec/plugin/middleware_spec.rb
roda-cj-0.9.1 spec/plugin/middleware_spec.rb
roda-0.9.0 spec/plugin/middleware_spec.rb