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: {})
============================================================