Skip to content

Instantly share code, notes, and snippets.

@detomastah
Created May 16, 2015 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save detomastah/7c7c8e340e4ec69abf90 to your computer and use it in GitHub Desktop.
Save detomastah/7c7c8e340e4ec69abf90 to your computer and use it in GitHub Desktop.
Failure/Error: post :notification, { "communication_id" => "666", "content" => {"id_sale" => 123} }
WebMock::NetConnectNotAllowedError:
Real HTTP connections are disabled. Unregistered request: POST https://direct.paylane.com/rest/sales/info with body '{"id_sale":"123"}' with headers {'Authorization'=>'Basic ZGV0b21hc3RhaDpodTJzd2U0ag==', 'Connection'=>'close', 'Content-Type'=>'application/json', 'Host'=>'direct.paylane.com', 'User-Agent'=>'RubyHTTPGem/0.8.4'}
You can stub this request with the following snippet:
stub_request(:post, "https://direct.paylane.com/rest/sales/info").
with(:body => "{\"id_sale\":\"123\"}",
:headers => {'Authorization'=>'Basic ZGV0b21hc3RhaDpodTJzd2U0ag==', 'Connection'=>'close', 'Content-Type'=>'application/json', 'Host'=>'direct.paylane.com', 'User-Agent'=>'RubyHTTPGem/0.8.4'}).
to_return(:status => 200, :body => "", :headers => {})
registered request stubs:
stub_request(:post, "https://direct.paylane.com/rest/sales/info").
with(:body => "{\"id_sale\":\"123\"}",
:headers => {'Authorization'=>'Basic emx5Omh1MnN3ZTRq', 'Connection'=>'close', 'Content-Type'=>'application/json', 'Host'=>'direct.paylane.com', 'User-Agent'=>'RubyHTTPGem/0.8.4'})
============================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment