Created
July 11, 2012 12:31
-
-
Save kenoir/3090084 to your computer and use it in GitHub Desktop.
For loading javascript into files into a page with capybara
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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