2017-10-16 04:37:53 -04:00
|
|
|
require 'io/console'
|
|
|
|
|
|
|
|
module LiveDebugger
|
|
|
|
def live_debug
|
2017-10-17 11:42:21 -04:00
|
|
|
puts "\nCurrent example is paused for live debugging."
|
|
|
|
puts "Opening #{current_url} in your default browser..."
|
2017-10-16 04:37:53 -04:00
|
|
|
puts "The current user credentials are: #{@current_user.username} / 12345678" if @current_user
|
2017-10-17 11:42:21 -04:00
|
|
|
puts "Press '^C' to continue the execution of the example"
|
2017-10-16 04:37:53 -04:00
|
|
|
|
2017-10-17 11:42:21 -04:00
|
|
|
`open #{current_url}`
|
|
|
|
|
|
|
|
catch :unpause_test do
|
|
|
|
trap('INT') { throw :unpause_test }
|
|
|
|
loop do
|
|
|
|
sleep(1)
|
2017-10-16 04:37:53 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-17 11:42:21 -04:00
|
|
|
# If the command is 'DEFAULT', the Ruby's default handler will be invoked.
|
|
|
|
# http://docs.rubydocs.org/rails-4-2-8-ruby-2-3-4/Ruby%202.3.4/classes/Kernel.html#method-i-trap
|
|
|
|
trap('INT') { 'DEFAULT' }
|
|
|
|
|
2017-10-16 04:37:53 -04:00
|
|
|
puts "Back to the example!"
|
|
|
|
end
|
|
|
|
end
|