I need to mock an external API request as part of a new cucumber test. My usual practice is to first write the test that makes the call, and expect WebMock to complain about it. Then using the information that WebMock provides, stub the request.
But in this repo (which is new to me), WebMock does not intercept the request. It just times out. Even more curious, it behaves exactly as I expect in rspec (it intercepts my request attempt, and tells me how to mock it), but not in cucumber.
I DO have this in features\support\webmock.rb:
WebMock.disable_net_connect!(:allow_localhost => true)
I've also tried putting that same line in features\support\env.rb
. Still allows the request.
I can figure out how to stub this another way, of course, but it bothers me that my tests could be making live calls if I make a mistake. Can anyone help?
UPDATE:
I've determined that (:allow_localhost => true)
does indeed keep the external requests from being made, but it does not trigger the WebMock mechanism that shows the bad request (I assume by rescuing an exception), and instead the request simply times out. Still don't know why.
UPDATE 2:
I've found the problem. This repo uses a custom client gem to talk to another internal service. That gem rescues connection errors, and thus the webmock error gets swallowed.