Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
a3368a98
Commit
a3368a98
authored
Oct 17, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve the LiveDebugger exit handler and documentation
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
9bccea6e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
doc/development/testing_guide/best_practices.md
doc/development/testing_guide/best_practices.md
+2
-2
spec/support/live_debugger.rb
spec/support/live_debugger.rb
+13
-9
No files found.
doc/development/testing_guide/best_practices.md
View file @
a3368a98
...
@@ -62,10 +62,10 @@ writing one](testing_levels.md#consider-not-writing-a-system-test)!
...
@@ -62,10 +62,10 @@ writing one](testing_levels.md#consider-not-writing-a-system-test)!
Sometimes you may need to debug Capybara tests by observing browser behavior.
Sometimes you may need to debug Capybara tests by observing browser behavior.
You can
stall
Capybara and view the website on the browser by using the
You can
pause
Capybara and view the website on the browser by using the
`live_debug`
method in your spec. The current page will be automatically opened
`live_debug`
method in your spec. The current page will be automatically opened
in your default browser.
in your default browser.
You may need to sign
-
in first (the current user's credentials are displayed in
You may need to sign
in first (the current user's credentials are displayed in
the terminal).
the terminal).
To resume the test run, you only need to press
`c`
.
To resume the test run, you only need to press
`c`
.
...
...
spec/support/live_debugger.rb
View file @
a3368a98
...
@@ -2,20 +2,24 @@ require 'io/console'
...
@@ -2,20 +2,24 @@ require 'io/console'
module
LiveDebugger
module
LiveDebugger
def
live_debug
def
live_debug
`open
#{
current_url
}
`
puts
"
\n
Current example is paused for live debugging."
puts
"Opening
#{
current_url
}
in your default browser..."
puts
"
\n
Current example is paused for live debugging"
puts
"The current user credentials are:
#{
@current_user
.
username
}
/ 12345678"
if
@current_user
puts
"The current user credentials are:
#{
@current_user
.
username
}
/ 12345678"
if
@current_user
puts
"Press '
c
' to continue the execution of the example"
puts
"Press '
^C
' to continue the execution of the example"
loop
do
`open
#{
current_url
}
`
if
$stdin
.
getch
==
'c'
break
catch
:unpause_test
do
else
trap
(
'INT'
)
{
throw
:unpause_test
}
puts
"Please press 'c' to continue the execution of the example! ;)"
loop
do
sleep
(
1
)
end
end
end
end
# 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'
}
puts
"Back to the example!"
puts
"Back to the example!"
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment