From 98fb0e63fae8f44fb917836c5367ca6bf5fc8d85 Mon Sep 17 00:00:00 2001 From: San Kim Date: Mon, 18 May 2020 18:07:25 +0900 Subject: [PATCH] Initialize @pattern as symbol in MethodPattern --- lib/webmock/request_pattern.rb | 2 +- spec/unit/request_pattern_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/webmock/request_pattern.rb b/lib/webmock/request_pattern.rb index 5598cbf55..4c41b0e6f 100644 --- a/lib/webmock/request_pattern.rb +++ b/lib/webmock/request_pattern.rb @@ -92,7 +92,7 @@ def create_uri_pattern(uri) class MethodPattern def initialize(pattern) - @pattern = pattern + @pattern = pattern.to_sym end def matches?(method) diff --git a/spec/unit/request_pattern_spec.rb b/spec/unit/request_pattern_spec.rb index 68f39d35b..f92eb2833 100644 --- a/spec/unit/request_pattern_spec.rb +++ b/spec/unit/request_pattern_spec.rb @@ -91,6 +91,11 @@ def match(request_signature) to match(WebMock::RequestSignature.new(:get, "www.example.com")) end + it "should match if method is described as string" do + expect(WebMock::RequestPattern.new("any", "www.example.com")). + to match(WebMock::RequestSignature.new(:get, "www.example.com")) + end + it "should match if request has unescaped uri" do expect(WebMock::RequestPattern.new(:get, "www.example.com/my%20path")). to match(WebMock::RequestSignature.new(:get, "www.example.com/my path"))