Skip to content

Commit

Permalink
do not convert RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher to_s
Browse files Browse the repository at this point in the history
  • Loading branch information
luk4s committed May 1, 2018
1 parent 15fc3f1 commit 5122822
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/webmock/util/values_stringifier.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class WebMock::Util::ValuesStringifier
def self.stringify_values(value)
case value
when nil
value
when String, Numeric, TrueClass, FalseClass
value.to_s
when Hash
Hash[
value.map do |k, v|
Expand All @@ -14,7 +14,7 @@ def self.stringify_values(value)
stringify_values(v)
end
else
value.to_s
value
end
end
end
8 changes: 8 additions & 0 deletions spec/acceptance/shared/stubbing_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/x-www-form-urlencoded'},
body: "foo=1").status).to eq("200")
end

it "should match if stubbed request body is hash_included" do
WebMock.reset!
stub_request(:post, "www.example.com").with(body: {"foo" => hash_including("bar" => '1')})
expect(http_request(
:post, "http://www.example.com/", headers: {'Content-Type' => 'application/x-www-form-urlencoded'},
body: "foo[bar]=1").status).to eq("200")
end
end
end

Expand Down

0 comments on commit 5122822

Please sign in to comment.