I have this code
require 'mechanize'
@agent = Mechanize.new
page = @agent.get('http://something.com/?page=1')
next_page = page.link_with(:href=>/^?page=2/).click
As you can see this code should go to the next page.
The next_page should have url http://something.com/?page=2
How to get current url for next_page?
See http://www.rubydoc.info/gems/mechanize/Mechanize/Page/Link#uri-instance_method and http://ruby-doc.org/stdlib-2.4.1/libdoc/uri/rdoc/URI.html
For testing purposes, I did the following in irb: