sparklemotion/mechanize — pull request #328 by gjorquera (2013-08-14 00:57:15+00:00)
Title: Add bang version to #{singular}_with matchers.

Sometimes you might find that the page you are downloading and working with has
changed. If this is the case then some elements might no longer exists, and you
will start be getting empty lists, nil objects and NoMethodErrors.

This bang version will raise a more according ElementNotFoundError for the
singular version of the element matchers (${singular}_with!), so you can rescue
it and do something to try to notify that the element you are expecting no
longer exists.

For example,

page.form_with(:name => 'no form') { |f| f.foo = 'bar' }
# NoMethodError for NilClass

page.form_with!(:name => 'no form') { |f| f.foo = 'bar' }
# Mechanize::ElementNotFoundError