I'm trying to use the Ruby gem Mechanize in an app I'm building, but I'm getting an error.
Performing the following in IRB with Ruby 1.9.3-p0:
require 'Mechanize'
agent = Mechanize.new
page = agent.get('http://www.google.com')
Gives me the following error:
NoMethodError: undefined method `info' for nil:NilClass
from ~/.rvm/gems/ruby-1.9.3-p0@global/gems/net-http-spy-0.2.1/lib/net-http-spy.rb:24:in 'initialize'
The initialize block of net-http-spy.rb looks like this:
def initialize(*args, &block)
self.class.http_logger_options ||= {}
defaults = {:body => false, :trace => false, :verbose => false, :limit => -1}
self.class.http_logger_options = (self.class.http_logger_options == :default) ? defaults : self.class.http_logger_options
@logger_options = defaults.merge(self.class.http_logger_options)
@params_limit = @logger_options[:params_limit] || @logger_options[:limit]
@body_limit = @logger_options[:body_limit] || @logger_options[:limit]
self.class.http_logger.info "CONNECT: #{args.inspect}" if !@logger_options[:verbose]
old_initialize(*args, &block)
@debug_output = self.class.http_logger if @logger_options[:verbose]
end
It appears to be the line starting self.class.http_logger.info
which is causing problem, I'm just not sure why. Can anyone shed any light as to what I'm doing wrong?