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 And a task which executes as root
Scenario: Switching from default user to root and back again 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" When I run cap "am_i_root"
Then the task is successful Then the task is successful
And contains "root" in the output And the output matches "I am uid=0\(root\)" followed by "I am uid=\d+\(vagrant\)"
Then I run cap "git:check"
Then the task is successful
And references in the remote repo are listed

View file

@ -106,10 +106,14 @@ When(/^an error is raised$/) do
run_vagrant_command(test_file_exists(error)) run_vagrant_command(test_file_exists(error))
end end
Then(/contains "(.*?)" in the output/) do |expected| Then(/contains "([^"]*)" in the output/) do |expected|
expect(@output).to include(expected) expect(@output).to include(expected)
end 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) expect(@output).not_to include(expected)
end end

View file

@ -4,4 +4,8 @@ task :am_i_root do
ident = capture :id, '-a' ident = capture :id, '-a'
info "I am #{ident}" info "I am #{ident}"
end end
on roles(:all) do |host|
ident = capture :id, '-a'
info "I am #{ident}"
end
end end