1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Improve Cucumber tests

The test for SSH connection name switching was faulty
Improve the regexes used in the assertions
This commit is contained in:
Nick Townsend 2015-02-14 11:32:42 -08:00
parent 5c9b27e90d
commit 263295c423
3 changed files with 11 additions and 9 deletions

View file

@ -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\)"

View file

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

View file

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