[MacRuby] #1182: The Mechanize Gem Fails Under MacRuby But Runs Under Ruby 1.9.2

MacRuby ruby-noreply at macosforge.org
Sun Mar 13 01:39:35 PST 2011

#1182: The Mechanize Gem Fails Under MacRuby But Runs Under Ruby 1.9.2
 Reporter:  dekiefer@…              |       Owner:  lsansonetti@…        
     Type:  defect                  |      Status:  new                  
 Priority:  minor                   |   Milestone:  MacRuby 0.10         
Component:  MacRuby                 |    Keywords:  Mechanize gem        

Comment(by cyberfox@…):

 I've gotten Mechanize to work by killing off a few odd pieces.
 Specifically, if I remove the entire {{{pretty_inspect}}} section (I
 killed from the 1.8.4 comment down), and I remove {{{require
 'mechanize/inspect'}}} from {{{mechanize.rb}}} it works a LOT better.

 It still doesn't set {{{mech}}} in new instances, so you have to do that
 by hand.  I.e.
 {{{a = Mechanize.new { |agent| agent.user_agent = "Mozilla/5.0 (Macintosh;
 U; Intel Mac OS X 10.6; en-US; rv: Gecko/20101203
 b = a.get('http://example.com')
 b.mech = a
 c = b.link_with(:text => /text of a link/).href
 d = a.get(c)
 d.mech = a
 puts d.search('td.inf_lab')[1].parent.children[0].content
 puts d.search('td.inf_lab')[1].parent.children[1].content

 I'm guessing that the MacRuby failure comes in when it's doing some
 complex code for inherited instance variables, or something like that.

 Still, those changes get me able to use Mechanize, with some minor
 caveats, which is nice...

 --  Morgan Schweers

Ticket URL: <http://www.macruby.org/trac/ticket/1182#comment:1>
MacRuby <http://macruby.org/>

More information about the macruby-tickets mailing list