Skip to content

@goblin /app.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Something went wrong with that request. Please try again.