Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

wrote a test for weird characters in query string

When stub_request contains weird characters like + and / in the query string,
the error messages returned by rspec ("You can stub this request with")
contain "%20"s in the URL instead of %2B or %2F. This tests for that.
  • Loading branch information...
commit 1596f6bc370de2e4510ac3f399e9a3938fc18450 1 parent 5662ca4
goblin authored October 03, 2012
17  spec/acceptance/em_http_request/em_http_request_spec.rb
@@ -205,6 +205,23 @@ def response(resp)
205 205
       http_request(:post, "http://www.example.com").body.bytesize.should == body.bytesize
206 206
     end
207 207
 
  208
+    context "in presence of special characters in the request" do
  209
+      it "should correctly tell the user how to stub" do
  210
+        WebMock.disable_net_connect!
  211
+        begin
  212
+          http_request(:get, "http://www.example.com/?foo=a+/b=c")
  213
+        rescue WebMock::NetConnectNotAllowedError => e
  214
+          e.message.should match /Unregistered request: GET http:\/\/www\.example\.com\/\?foo=a%2B\/b=c/m
  215
+          e.message.should match /stub_request\(:get, "http:\/\/www\.example\.com\/\?foo=a%2B\/b=c"\)/m
  216
+        rescue Exception => e
  217
+          fail "unknown exception #{e.message}"
  218
+        else
  219
+          fail "unknown error"
  220
+        end
  221
+
  222
+      end
  223
+    end
  224
+
208 225
     describe "mocking EM::HttpClient API" do
209 226
       let(:uri) { "http://www.example.com/" }
210 227
 

0 notes on commit 1596f6b

Please sign in to comment.
Something went wrong with that request. Please try again.