@@ -206,12 +206,18 @@ defmodule Plug.RouterTest do
206206 forward "/plug/init_opts" , to: plug , init_opts: opts , private: % { baz: :qux }
207207
208208 forward "/plug/forward_local" , to: :forward_local
209+ match "/plug/match_local" , to: :match_local
209210 forward "/plug/forward_local_opts" , to: :forward_local , init_opts: opts , private: % { baz: :qux }
211+ match "/plug/match_local_opts" , to: :match_local , init_opts: opts , private: % { baz: :qux }
210212
211213 def forward_local ( conn , opts ) do
212214 resp ( conn , 200 , "#{ inspect ( opts ) } " )
213215 end
214216
217+ def match_local ( conn , opts ) do
218+ resp ( conn , 200 , "#{ inspect ( opts ) } " )
219+ end
220+
215221 match _ do
216222 resp ( conn , 404 , "oops" )
217223 end
@@ -587,12 +593,23 @@ defmodule Plug.RouterTest do
587593 assert conn . resp_body == "[]"
588594 end
589595
596+ test "matches to a function plug" do
597+ conn = call ( Sample , conn ( :get , "/plug/match_local" ) )
598+ assert conn . resp_body == "[]"
599+ end
600+
590601 test "forwards to a function plug with options" do
591602 conn = call ( Sample , conn ( :get , "/plug/forward_local_opts" ) )
592603 assert conn . private [ :baz ] == :qux
593604 assert conn . resp_body == ":hello"
594605 end
595606
607+ test "matches to a function plug with options" do
608+ conn = call ( Sample , conn ( :get , "/plug/match_local_opts" ) )
609+ assert conn . private [ :baz ] == :qux
610+ assert conn . resp_body == ":hello"
611+ end
612+
596613 test "emit start and stop event when router dispatches" do
597614 start_router_id = { :start , :rand . uniform ( 100 ) }
598615 stop_router_id = { :stop , :rand . uniform ( 100 ) }
0 commit comments