Skip to content

Instantly share code, notes, and snippets.

View alexpapworth's full-sized avatar
👋
hi!

Alex Papworth alexpapworth

👋
hi!
View GitHub Profile
@beccasaurus
beccasaurus / define_function.rb
Created August 12, 2011 22:25
Capybara helper for defining a JavaScript function in a page (globally, attached to window)
# Given the name and body for a JavaScript function, this defines the
# function globally in the page.
#
# This is most useful for making helper JavaScript functions that you can
# call later, eg. foo = evaluate_script('myFunction()')
#
# Usage:
#
# page.define_function :whatever, %{
# var foo = 'hello';