1

I'm trying to add some system tests in my already existing application written in Ruby On Rails. I've already updated the application to Rails 5.1.

When I execute the test, the result is it:

E

Error:
ResponsibleProductsAvailableForStudentsTest#test_responsible_should_not_browse_products_available_for_other_responsible_student:
WebMock::NetConnectNotAllowedError: Real HTTP connections are disabled. 
Unregistered request: POST http://127.0.0.1:9515/session with body 
'{"desiredCapabilities":{"browserName":"chrome","version":"","platform":"ANY","javascriptEnabled":true,"cssSelectorsEnabled":true,"takesScreenshot":false,"nativeEvents":false,"rotatable":false}}' with headers {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'193', 'Content-Type'=>'application/json; charset=utf-8', 'User-Agent'=>'Ruby'}

You can stub this request with the following snippet:

stub_request(:post, "http://127.0.0.1:9515/session").
with(body: "{\"desiredCapabilities\":
{\"browserName\":\"chrome\",\"version\":\"\",\"platform\":\"ANY\", \"javascriptEnabled\":true,\"cssSelectorsEnabled\":true,\"takesScreenshot\":false,\"nativeEvents\":false,\"rotatable\":false}}",
headers: {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'193', 'Content-Type'=>'application/json; charset=utf-8', 'User-Agent'=>'Ruby'}).
to_return(status: 200, body: "", headers: {})

============================================================
evandrolg
  • 65
  • 2
  • 10
  • Possible duplicate of ["Real HTTP connections are disabled" error when trying test OmniAuth with RSpec](http://stackoverflow.com/questions/20462618/real-http-connections-are-disabled-error-when-trying-test-omniauth-with-rspec) – Bohdan May 04 '17 at 16:11
  • So, actually it was a problem with WebMock. Adding this line `WebMock.disable_net_connect!(allow_localhost: true) `, that error was solved. Now I've a new problem, it seems really strange one: `[NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html [IMPORTANT] Don't forget to include the Crash Report log file under DiagnosticReports directory in bug reports.` – evandrolg May 04 '17 at 18:39
  • please add new question for that issue if you haven't done it yet – Bohdan May 05 '17 at 03:06

0 Answers0