Skip to content
This repository

request_pattern should handle content_types that specify a charset #194

Merged
merged 1 commit into from almost 2 years ago

2 participants

Kevin Glowacz Bartosz Blimke
Kevin Glowacz
kjg commented July 12, 2012

No description provided.

Bartosz Blimke
Owner

Thank you for this pull request. Looks good.

Bartosz Blimke bblimke merged commit 1e61a8c into from July 23, 2012
Bartosz Blimke bblimke closed this July 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 12, 2012
Kevin Glowacz request_pattern should handle content_types that specify a charset 824c336
This page is out of date. Refresh to see the latest.
1  lib/webmock/request_pattern.rb
@@ -27,6 +27,7 @@ def with(options = {}, &block)
27 27
 
28 28
     def matches?(request_signature)
29 29
       content_type = request_signature.headers['Content-Type'] if request_signature.headers
  30
+      content_type = content_type.split(';').first if content_type
30 31
       @method_pattern.matches?(request_signature.method) &&
31 32
         @uri_pattern.matches?(request_signature.uri) &&
32 33
         (@body_pattern.nil? || @body_pattern.matches?(request_signature.body, content_type || "")) &&
7  spec/unit/request_pattern_spec.rb
@@ -358,6 +358,13 @@ def match(request_signature)
358 358
               should_not match(WebMock::RequestSignature.new(:post, "www.example.com",
359 359
                                                              :headers => {:content_type => 'application/xml'}, :body => "foo bar"))
360 360
               end
  361
+
  362
+          it "matches when the content type include a charset" do
  363
+            WebMock::RequestPattern.new(:post, 'www.example.com', :body => body_hash).
  364
+              should match(WebMock::RequestSignature.new(:post, "www.example.com", :headers => {:content_type => 'application/xml;charset=UTF-8'},
  365
+                                                         :body => "<opt a=\"1\" b=\"five\">\n  <c>\n    <d>e</d>\n    <d>f</d>\n  </c>\n</opt>\n"))
  366
+
  367
+          end
361 368
         end
362 369
       end
363 370
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.