webmock 是否自动检测 url 中的 `?`

Does webmock auto detects `?` in the url

我正在使用 webmock 来存根请求。 我使用以下代码存根请求。

stub_request(:delete, "https://graph.facebook.com/v2.0/1741/likes?access_token=this_is_a_test_token").to_return(body: "true")

我收到以下错误:-

WebMock::NetConnectNotAllowedError:
       Real HTTP connections are disabled. Unregistered request: DELETE https://graph.facebook.com/v2.0/1741/likes with body 'access_token=this_is_a_test_token' with headers {'Accept'=>'*/*', 'Content-Type'=>'application/x-www-form-urlencoded', 'Date'=>'Sun, 19 Apr 2015 08:43:06 GMT', 'User-Agent'=>'FbGraph2 (0.5.0) (2.5.1, ruby 2.1.2 (2014-05-08))'}

       You can stub this request with the following snippet:

       stub_request(:delete, "https://graph.facebook.com/v2.0/1741/likes").
         with(:body => {"access_token"=>"this_is_a_test_token"},
              :headers => {'Accept'=>'*/*', 'Content-Type'=>'application/x-www-form-urlencoded', 'Date'=>'Sun, 19 Apr 2015 08:43:06 GMT', 'User-Agent'=>'FbGraph2 (0.5.0) (2.5.1, ruby 2.1.2 (2014-05-08))'}).
         to_return(:status => 200, :body => "", :headers => {})

       registered request stubs:

       stub_request(:delete, "https://graph.facebook.com/v2.0/1741/likes?access_token=this_is_a_test_token")

它在我使用 http://...com/1741/likes 之前工作正常,我只是在添加命名空间的存根请求中进行了更改 v2.0,但测试用例已损坏。

您已更改要存根的 URL。您应该使用 with 方法参数中指定的查询参数显示的消息存根!