-
-
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.
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 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