Skip to content

Instantly share code, notes, and snippets.

@hakanensari
Created October 26, 2011 09:37
Show Gist options
  • Save hakanensari/1315898 to your computer and use it in GitHub Desktop.
Save hakanensari/1315898 to your computer and use it in GitHub Desktop.
Debug Ruby Mechanize page in browser
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