Skip to content

Commit

Permalink
Rescue exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
c960657 committed Aug 2, 2024
1 parent a7bb2fc commit 69c45b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/webmock/request_pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def body_as_hash(body, content_type)
else
WebMock::Util::QueryMapper.query_to_values(body, notation: Config.instance.query_values_notation)
end
rescue Psych::SyntaxError, REXML::ParseException
end

def body_format(content_type)
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/request_pattern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def match(request_signature)
it "should not match when body is not json" do
expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
headers: {content_type: content_type}, body: "foo bar"))
headers: {content_type: content_type}, body: "[foo bar"))
end

it "should not match if request body is different" do
Expand Down Expand Up @@ -614,7 +614,7 @@ def match(request_signature)
it "should not match when body is not xml" do
expect(WebMock::RequestPattern.new(:post, 'www.example.com', body: body_hash)).
not_to match(WebMock::RequestSignature.new(:post, "www.example.com",
headers: {content_type: content_type}, body: "foo bar"))
headers: {content_type: content_type}, body: "<foo bar"))
end

it "matches when the content type include a charset" do
Expand Down

0 comments on commit 69c45b8

Please sign in to comment.