If you’re using WebMock in your specs, then add the following to your rails_helper.rb:
WebMock.allow_net_connect!(net_http_connect_on_start: true)
or
WebMock.disable_net_connect!(net_http_connect_on_start: true)
source: https://github.com/bblimke/webmock/blob/master/README.md#connecting-on-nethttpstart