martinbtt/net-http-spy — Issue #2: Error when using with mechanize
Author: janlelis
Created: 2012-02-18 10:27:23+00:00
State: open

An error is raised when using the spy on mechanize:

$ irb -f
>> require 'net-http-spy'
>> require 'mechanize'
>> a = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }
>> a.get "http://heise.de"
NoMethodError: undefined method `info' for nil:NilClass
from .rvm/gems/ruby-1.9.3-p0/gems/net-http-spy-0.2.1/lib/net-http-spy.rb:24:in `initialize'
from .rvm/gems/ruby-1.9.3-p0/gems/net-http-persistent-2.5.2/lib/net/http/persistent/ssl_reuse.rb:19:in `initialize'
from .rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:569:in `new'
from .rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:569:in `new'
from .rvm/gems/ruby-1.9.3-p0/gems/net-http-persistent-2.5.2/lib/net/http/persistent.rb:495:in `connection_for'
from .rvm/gems/ruby-1.9.3-p0/gems/net-http-persistent-2.5.2/lib/net/http/persistent.rb:788:in `request'
from .rvm/gems/ruby-1.9.3-p0/gems/mechanize-2.2.1/lib/mechanize/http/agent.rb:228:in `fetch'
from .rvm/gems/ruby-1.9.3-p0/gems/mechanize-2.2.1/lib/mechanize.rb:403:in `get'
from (irb):6
from .rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `

'

Works fine without the spy.