@@ -376,6 +376,42 @@ def match(request_signature)
376376 end
377377 end
378378
379+ describe "when uri is described as Addressable::URI" do
380+ it "should match request query params" do
381+ expect ( WebMock ::RequestPattern . new ( :get , Addressable ::URI . parse ( "www.example.com" ) , query : { "a" => [ "b" , "c" ] } ) ) .
382+ to match ( WebMock ::RequestSignature . new ( :get , "www.example.com?a[]=b&a[]=c" ) )
383+ end
384+
385+ it "should not match request query params if params don't match" do
386+ expect ( WebMock ::RequestPattern . new ( :get , Addressable ::URI . parse ( "www.example.com" ) , query : { "x" => [ "b" , "c" ] } ) ) .
387+ not_to match ( WebMock ::RequestSignature . new ( :get , "www.example.com?a[]=b&a[]=c" ) )
388+ end
389+
390+ it "should match when query params are declared as HashIncluding matcher matching params" do
391+ expect ( WebMock ::RequestPattern . new ( :get , Addressable ::URI . parse ( "www.example.com" ) ,
392+ query : WebMock ::Matchers ::HashIncludingMatcher . new ( { "a" => [ "b" , "c" ] } ) ) ) .
393+ to match ( WebMock ::RequestSignature . new ( :get , "www.example.com?a[]=b&a[]=c&b=1" ) )
394+ end
395+
396+ it "should not match when query params are declared as HashIncluding matcher not matching params" do
397+ expect ( WebMock ::RequestPattern . new ( :get , Addressable ::URI . parse ( "www.example.com" ) ,
398+ query : WebMock ::Matchers ::HashIncludingMatcher . new ( { "x" => [ "b" , "c" ] } ) ) ) .
399+ not_to match ( WebMock ::RequestSignature . new ( :get , "www.example.com?a[]=b&a[]=c&b=1" ) )
400+ end
401+
402+ it "should match when query params are declared as RSpec HashIncluding matcher matching params" do
403+ expect ( WebMock ::RequestPattern . new ( :get , Addressable ::URI . parse ( "www.example.com" ) ,
404+ query : RSpec ::Mocks ::ArgumentMatchers ::HashIncludingMatcher . new ( { "a" => [ "b" , "c" ] } ) ) ) .
405+ to match ( WebMock ::RequestSignature . new ( :get , "www.example.com?a[]=b&a[]=c&b=1" ) )
406+ end
407+
408+ it "should not match when query params are declared as RSpec HashIncluding matcher not matching params" do
409+ expect ( WebMock ::RequestPattern . new ( :get , Addressable ::URI . parse ( "www.example.com" ) ,
410+ query : RSpec ::Mocks ::ArgumentMatchers ::HashIncludingMatcher . new ( { "a" => [ "b" , "d" ] } ) ) ) .
411+ not_to match ( WebMock ::RequestSignature . new ( :get , "www.example.com?a[]=b&a[]=c&b=1" ) )
412+ end
413+ end
414+
379415 describe "when uri is described as string" do
380416 it "should match when query params are the same as declared in hash" do
381417 expect ( WebMock ::RequestPattern . new ( :get , "www.example.com" , query : { "a" => [ "b" , "c" ] } ) ) .
0 commit comments