Skip to content

Commit

Permalink
Mechanize#click now works with regualr expressions.
Browse files Browse the repository at this point in the history
  • Loading branch information
orangea authored and tenderlove committed Oct 3, 2010
1 parent c0d8f47 commit fb68084
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.rdoc
Expand Up @@ -6,8 +6,9 @@

* Add header reference methods to Mechanize::File so that a reponse
object gets compatible with Net::HTTPResponse.
* Mechanize#click accepts a string to click a button/link in the current
page. It works as expected when not passed a string.
* Mechanize#click accepts a regexp or string to click a button/link
in the current page. It works as expected when not passed a
string or regexp.

* Bug Fixes:

Expand Down
3 changes: 2 additions & 1 deletion lib/mechanize.rb
Expand Up @@ -313,7 +313,8 @@ def get_file(url)
# value of the string and clicks it. Otherwise, clicks the
# Mechanize::Page::Link object passed in. Returns the page fetched.
def click(link)
if link.is_a? String
case link
when String, Regexp
if real_link = page.link_with(:text => link)
click real_link
else
Expand Down

0 comments on commit fb68084

Please sign in to comment.