Skip to content

Instantly share code, notes, and snippets.

@henrik
Created November 25, 2011 12:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save henrik/1393426 to your computer and use it in GitHub Desktop.
Save henrik/1393426 to your computer and use it in GitHub Desktop.
show_page debug helper for RSpec request specs that opens or reloads page in Chrome.
module RequestDebugHelpers
DEBUG_URL = "http://example.dev/debug.html"
def show_page
filename = File.join(Rails.root, 'public', 'debug.html')
File.open(filename, 'w') do |f|
f.puts page.body.gsub("</title>", " (#{ current_path })\\0")
end
system "osascript", "-e", <<-OSASCRIPT
tell application "Google Chrome" to tell the active tab of the first window
if URL is "#{DEBUG_URL}"
reload
else
do shell script "open -a 'Google Chrome' -g '#{DEBUG_URL}'"
end if
end tell
OSASCRIPT
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment