Skip to content

Instantly share code, notes, and snippets.

@ratbeard
Last active December 17, 2015 04:29
Show Gist options
  • Save ratbeard/5550740 to your computer and use it in GitHub Desktop.
Save ratbeard/5550740 to your computer and use it in GitHub Desktop.
class PageObject
def click
puts 'click'
end
def submit
puts 'submit'
end
def wait_for_ajax
puts "waiting for ajax..."
end
end
module AjaxEverything
%w(click submit).each {|m|
class_eval "def #{m}(*); wait_for_ajax; super; end"
}
end
class CoolPage < PageObject
include AjaxEverything
end
CoolPage.new.click
# => waiting for ajax...
# => click
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment