Browse files

Handles the case where the match is an array of Regex.

The matcher falls over if the post request contains an array, and the
array contains a Regex, since ['a'] != [/*./].
  • Loading branch information...
1 parent 5662ca4 commit 280cbc1ad7e79a95cb9db9bcbf7569d3f220196e Nicholas Johnson committed Oct 18, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/webmock/request_pattern.rb
View
4 lib/webmock/request_pattern.rb
@@ -236,6 +236,10 @@ def matching_hashes?(query_parameters, pattern)
if actual.is_a?(Hash) && expected.is_a?(Hash)
return false unless matching_hashes?(actual, expected)
+ elsif actual.is_a?(Array) && expected.is_a?(Array)
+ actual_as_hash = Hash[actual.each_with_index.map { |x,i| [i+1, x] }]
+ expected_as_hash = Hash[expected.each_with_index.map { |x,i| [i+1, x] }]
+ return false unless matching_hashes?(actual_as_hash, expected_as_hash)
else
return false unless expected === actual
end

0 comments on commit 280cbc1

Please sign in to comment.