Skip to content

Instantly share code, notes, and snippets.

@chrismealy
Forked from henrik/request_debug_helpers.rb
Created July 18, 2012 23:05
Show Gist options
  • Save chrismealy/3139589 to your computer and use it in GitHub Desktop.
Save chrismealy/3139589 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