Skip to content

Instantly share code, notes, and snippets.

@jnjcub
Last active December 14, 2015 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnjcub/5159057 to your computer and use it in GitHub Desktop.
Save jnjcub/5159057 to your computer and use it in GitHub Desktop.
Webrat hack to create a method to update form action(or any form attribute)
module Webrat
class Scope
def update_form_attr(id, action)
ele = FormLocator.new(@session, dom, id).locate
ele.update({'action' => action})
end
end
class Form < Element #:nodoc:
def update(attr_hash = {})
attr_hash.each do |k,v|
@element[k] = v
end
end
end
class Session
def_delegators :current_scope, :update_form_attr
end
module Methods #:nodoc:
delegate_to_session \
:update_form_attr
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment