diff --git a/features/sshconnect.feature b/features/sshconnect.feature index addc1c5c..f6ee6354 100644 --- a/features/sshconnect.feature +++ b/features/sshconnect.feature @@ -6,12 +6,6 @@ Feature: SSH Connection And a task which executes as root Scenario: Switching from default user to root and back again - When I run cap "git:check" - Then the task is successful - And references in the remote repo are listed When I run cap "am_i_root" Then the task is successful - And contains "root" in the output - Then I run cap "git:check" - Then the task is successful - And references in the remote repo are listed + And the output matches "I am uid=0\(root\)" followed by "I am uid=\d+\(vagrant\)" diff --git a/features/step_definitions/assertions.rb b/features/step_definitions/assertions.rb index 3f2f472d..3e54ddd3 100644 --- a/features/step_definitions/assertions.rb +++ b/features/step_definitions/assertions.rb @@ -106,10 +106,14 @@ When(/^an error is raised$/) do run_vagrant_command(test_file_exists(error)) end -Then(/contains "(.*?)" in the output/) do |expected| +Then(/contains "([^"]*)" in the output/) do |expected| expect(@output).to include(expected) end -Then(/doesn't contain "(.*?)" in the output/) do |expected| +Then(/the output matches "([^"]*)" followed by "([^"]*)"/) do |expected, followedby| + expect(@output).to match(/#{expected}.*#{followedby}/m) +end + +Then(/doesn't contain "([^"]*)" in the output/) do |expected| expect(@output).not_to include(expected) end diff --git a/spec/support/tasks/root.rake b/spec/support/tasks/root.rake index 82e31143..c82a0f82 100644 --- a/spec/support/tasks/root.rake +++ b/spec/support/tasks/root.rake @@ -4,4 +4,8 @@ task :am_i_root do ident = capture :id, '-a' info "I am #{ident}" end + on roles(:all) do |host| + ident = capture :id, '-a' + info "I am #{ident}" + end end