Www::mechanize help

I installed the gem for WWW::Mechanize and the installer said it
successfully. I tried to create a test ruby script to see if it works
and i
get this error:

mechanize-test.rb:1:in `require’: no such file to load – mechanize
from lib/tasks/mechanize-test.rb:1

Am i doing something wrong? What is the proper way to require external
classes in ruby? Futhermore in a rails project? Anyone worked with
mechanize before? please help.

Here is the test script (which i copied from the example given on the
creator’s, Mike Neuman?, blog)

require ‘mechanize’

agent = WWW::Mechanize.new {|a| a.log = Logger.new(STDERR) }
page = agent.get(‘http://rubyforge.org/’)
link = page.links.find {|l| l.node.text =~ /Log In/ }
page = agent.click(link)
form = page.forms[1]
form.fields.find {|f| f.name == ‘form_loginname’}.value = ARGV[0]
form.fields.find {|f| f.name == ‘form_pw’}.value = ARGV[1]
page = agent.submit(form, form.buttons.first)
puts page.body

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs