Created
October 26, 2011 09:37
-
-
Save hakanensari/1315898 to your computer and use it in GitHub Desktop.
Debug Ruby Mechanize page in browser
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
begin | |
require 'launchy' | |
class Mechanize::Page | |
def open_in_browser | |
if body | |
file = File.new("/tmp/#{Time.now.to_i}.html", 'w') | |
file.write body | |
Launchy.open "file://#{file.path}" | |
system "sleep 2 && rm #{file.path} &" | |
end | |
end | |
end | |
rescue LoadError | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment