Sha256: 53b6c1d0eb944303785880450a4850670df72185dccc636094f8443d447e69ea
Contents?: true
Size: 1.4 KB
Versions: 9
Compression:
Stored size: 1.4 KB
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').must_equal 'a3' body('/b').must_equal 'b3' body('/a', 'REQUEST_METHOD'=>'POST').must_equal 'a2' body('/b', 'REQUEST_METHOD'=>'POST').must_equal 'b2' body('/a', 'REQUEST_METHOD'=>'PATCH').must_equal 'a2' body('/b', 'REQUEST_METHOD'=>'PATCH').must_equal 'b1' end it "makes it still possible to use the Roda app normally" do app(:middleware) do "a" end body.must_equal 'a' end it "is compatible with the multi_route plugin" do app(:bare) do plugin :multi_route plugin :middleware route("a") do |r| r.is "b" do "ab" end end route do |r| r.multi_route end end body('/a/b').must_equal 'ab' end end
Version data entries
9 entries across 9 versions & 1 rubygems