我正在使用 mechanize 并在使用脚本/控制台在 Rails 环境中进行测试时遇到继承问题。
当我这样写时:
require 'rubygems'
require 'mechanize'
agent = WWW::Mechanize.new
agent.get 'http://www.google.com'
一切正常。但是当我尝试像这样创建 WWW::Mechanize 的子类时:
require 'rubygems'
require 'mechanize'
class Alfa < WWW::Mechanize; end
agent = Alfa.new
agent.get 'http://www.google.com'
我收到以下错误:
NoMethodError:当你没有预料到它时,你有一个 nil 对象!从 /Library/Ruby/Gems/1.8/gems/mechanize-0.9.3/lib/www/mechanize/page.rb:77:in `parser' 评估 nil.parse 时发生错误
我错过了什么吗?
提前致谢