diff options
author | Rémy Coutable <remy@rymai.me> | 2017-10-16 10:37:53 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-10-16 10:50:12 +0200 |
commit | 9bccea6e3438e26479e0f38e7833286daa10ed5d (patch) | |
tree | 22c1445ed23e3e21b6603ab7a88237e2bf95535f /spec | |
parent | 88bd5fa274d0b9d9ccd8be26f83d422517880fe3 (diff) | |
download | gitlab-ce-9bccea6e3438e26479e0f38e7833286daa10ed5d.tar.gz |
Add LiveDebugger#live_debug to debug Capybara in feature tests.
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec_helper.rb | 1 | ||||
-rw-r--r-- | spec/support/live_debugger.rb | 21 | ||||
-rw-r--r-- | spec/support/login_helpers.rb | 10 |
3 files changed, 31 insertions, 1 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 48cacba6a8a..0dc417b3cb6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -49,6 +49,7 @@ RSpec.configure do |config| config.include LoginHelpers, type: :feature config.include SearchHelpers, type: :feature config.include WaitForRequests, :js + config.include LiveDebugger, :js config.include StubConfiguration config.include EmailHelpers, :mailer, type: :mailer config.include TestEnv diff --git a/spec/support/live_debugger.rb b/spec/support/live_debugger.rb new file mode 100644 index 00000000000..b15aba01e68 --- /dev/null +++ b/spec/support/live_debugger.rb @@ -0,0 +1,21 @@ +require 'io/console' + +module LiveDebugger + def live_debug + `open #{current_url}` + + puts "\nCurrent example is paused for live debugging" + puts "The current user credentials are: #{@current_user.username} / 12345678" if @current_user + puts "Press 'c' to continue the execution of the example" + + loop do + if $stdin.getch == 'c' + break + else + puts "Please press 'c' to continue the execution of the example! ;)" + end + end + + puts "Back to the example!" + end +end diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 3e117530151..2ca05bb1778 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -3,6 +3,14 @@ require_relative 'devise_helpers' module LoginHelpers include DeviseHelpers + # Overriding Devise::Test::IntegrationHelpers#sign_in to store @current_user + # since we may need it in LiveDebugger#live_debug. + def sign_in(resource, scope: nil) + super + + @current_user = resource + end + # Internal: Log in as a specific user or a new user of a specific role # # user_or_role - User object, or a role to create (e.g., :admin, :user) @@ -28,7 +36,7 @@ module LoginHelpers gitlab_sign_in_with(user, **kwargs) - user + @current_user = user end def gitlab_sign_in_via(provider, user, uid) |