I’ve been trying to stub open, the open-uri version, and I’m not succeeding.
I’ve tried doing the following but the request keeps going through:
Kernel.should_receive(:open).and_return("Whatever for now")
I’ve also tried to do
OpenURI::OpenRead.should_receive(:open).and_return("Whatever for now")
Since I tracked down that was where HTTP requests were made in OpenURI.
Thanks in advance for any suggestions!
I found a solution here on Stack Overflow after some more time on Google (I can’t believe I didn’t find this before).
Explanation taken from here and written by Tony Pitluga (not linkable).
So I did this and it all worked out: