Skip to content

Instantly share code, notes, and snippets.

@goblin
Created October 18, 2012 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goblin/3911514 to your computer and use it in GitHub Desktop.
Save goblin/3911514 to your computer and use it in GitHub Desktop.
webmock bug?
require 'excon'
class MyApp
def doit
e = Excon.new('http://google.com')
str = ''
e.request({
:method => 'GET',
:path => '/',
:response_block => lambda { |chunk, remaining, total|
str += chunk
}
})
return str
end
end
require 'webmock/rspec'
require './app'
describe 'app' do
it 'works' do
WebMock.disable_net_connect!
mystr = 'abcdef123'
stub_request(:get, 'http://google.com/').to_return(:status => 200,
:body => mystr)
a = MyApp.new
a.doit.should eq mystr
end
end
irb(main):001:0> require './app'
=> true
irb(main):002:0> puts MyApp.new.doit
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
=> nil
irb(main):003:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment