Skip to content

Instantly share code, notes, and snippets.

@kenoir
Created July 11, 2012 12:31
Show Gist options
  • Save kenoir/3090084 to your computer and use it in GitHub Desktop.
Save kenoir/3090084 to your computer and use it in GitHub Desktop.
For loading javascript into files into a page with capybara
module JSLoader
def read_file(file)
file = File.open(file, "rb")
contents = file.read
file.close
contents
end
def load_file(filename)
file_location = File.join(File.dirname(__FILE__),'js',filename)
js = JSLoader::read_file(file_location)
@page.execute_script(js);
end
def init(page)
@page = page
end
module_function :init, :load_file
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment