I have an issue with Mechanize::Cookie misbehaving and I want to trying to monkey patch it. My code:
class Mechanize::Cookie
class << self; alias_method :old_parse, :parse end
def self.parse(uri, str, log = Mechanize.log)
puts 'new parse!'
#str.gsub!(/domain[^;]*;/,'')
old_parse(uri, str, log)
end
end
when I add this, the cookies don't get added and I can't figure out why.
Edit: To see the problem try this code with and without the monkey patch:
agent = Mechanize.new
agent.get 'http://www.google.com/'
pp agent.cookie_jar
Without patch you will see a full cookie jar, with it an empty one.