Skip to content

Instantly share code, notes, and snippets.

@jwright
Created August 27, 2013 00:15
Show Gist options
  • Save jwright/6348272 to your computer and use it in GitHub Desktop.
Save jwright/6348272 to your computer and use it in GitHub Desktop.
Webmock mocking problem

Output

Failure/Error: subject.save html, filename
     WebMock::NetConnectNotAllowedError:
       Real HTTP connections are disabled. Unregistered request: PUT https://api-content.dropbox.com/1/files_put/auto/blog/processed/stuff.html?overwrite=true with body '<p>This is <em>great</em>, yo</p>
       ' with headers {'Accept'=>'*/*', 'Authorization'=>'Bearer blah', 'Content-Length'=>'34', 'Content-Type'=>'application/octet-stream', 'User-Agent'=>'OfficialDropboxRubySDK/1.6.1'}

       You can stub this request with the following snippet:

       stub_request(:put, "https://api-content.dropbox.com/1/files_put/auto/blog/processed/stuff.html?overwrite=true").
         with(:body => "<p>This is <em>great</em>, yo</p>\n",
              :headers => {'Accept'=>'*/*', 'Authorization'=>'Bearer blah', 'Content-Length'=>'34', 'Content-Type'=>'application/octet-stream', 'User-Agent'=>'OfficialDropboxRubySDK/1.6.1'}).
         to_return(:status => 200, :body => "", :headers => {})

       registered request stubs:

       stub_request(:put, "https://api-content.dropbox.com/1/files_put/auto/blog/processed/stuff.html?overwrite=true").
         with(:body => "<p>This is <em>great</em>, yo</p>\n",
              :headers => {'Accept'=>'*/*', 'Authorization'=>'Bearer blah', 'Content-Length'=>'34', 'Content-Type'=>'application/octet-stream', 'User-Agent'=>'OfficialDropboxRubySDK/1.6.1'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment