title: How to rspec mock open-uri?
body: <p>I have this simple code where I am sending http request and reading all the response.
  Here is my rails code</p>
  
  <pre><code>open("http://stackoverflow.com/questions/ask")
  </code></pre>
  
  <p>How can I write spec for this line of code. I dont have the option to use mocha and webmock. I can only use mocking framework of Rpsec.</p>
  
  <p>I have tried to use this statement </p>
  
  <pre><code>OpenURI.stub!(:open_uri).should_receive(:open).with("http://stackoverflow.com/questions/ask")
  </code></pre>
  
  <p>but i keep getting this error </p>
  
  <pre><code>RSpec::Mocks::MockExpectationError: (#&lt;RSpec::Mocks::MessageExpectation:0xd1a7914&gt;).open("http://stackoverflow.com/questions/ask")
  expected: 1 time
  received: 0 times
  </code></pre>