2017-02-09 20:35:50 -08:00
|
|
|
require "shellwords"
|
|
|
|
|
2013-09-27 11:45:55 +01:00
|
|
|
Then(/^references in the remote repo are listed$/) do
|
2016-02-28 17:16:11 -06:00
|
|
|
expect(@output).to include("refs/heads/master")
|
2013-09-27 11:45:55 +01:00
|
|
|
end
|
|
|
|
|
2016-05-17 16:25:38 +02:00
|
|
|
Then(/^git wrapper permissions are 0700$/) do
|
2017-02-09 20:35:50 -08:00
|
|
|
permissions_test = %Q([ $(stat -c "%a" #{TestApp.git_wrapper_path.shellescape}) == "700" ])
|
2017-07-05 07:32:58 +05:30
|
|
|
_stdout, _stderr, status = vagrant_cli_command("ssh -c #{permissions_test.shellescape}")
|
|
|
|
|
|
|
|
expect(status).to be_success
|
2016-05-17 16:25:38 +02:00
|
|
|
end
|
|
|
|
|
2013-09-27 11:45:55 +01:00
|
|
|
Then(/^the shared path is created$/) do
|
|
|
|
run_vagrant_command(test_dir_exists(TestApp.shared_path))
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^the releases path is created$/) do
|
|
|
|
run_vagrant_command(test_dir_exists(TestApp.releases_path))
|
|
|
|
end
|
|
|
|
|
2017-07-22 16:15:44 -07:00
|
|
|
Then(/^(\d+) valid releases are kept/) do |num|
|
|
|
|
test = %Q([ $(ls -g #{TestApp.releases_path} | grep -E '[0-9]{14}' | wc -l) == "#{num}" ])
|
|
|
|
_, _, status = vagrant_cli_command("ssh -c #{test.shellescape}")
|
|
|
|
expect(status).to be_success
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^the invalid (.+) release is ignored$/) do |filename|
|
|
|
|
test = "ls -g #{TestApp.releases_path} | grep #{filename}"
|
|
|
|
_, _, status = vagrant_cli_command("ssh -c #{test.shellescape}")
|
|
|
|
expect(status).to be_success
|
|
|
|
end
|
|
|
|
|
2013-09-27 11:45:55 +01:00
|
|
|
Then(/^directories in :linked_dirs are created in shared$/) do
|
|
|
|
TestApp.linked_dirs.each do |dir|
|
|
|
|
run_vagrant_command(test_dir_exists(TestApp.shared_path.join(dir)))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^directories referenced in :linked_files are created in shared$/) do
|
|
|
|
dirs = TestApp.linked_files.map { |path| TestApp.shared_path.join(path).dirname }
|
2016-02-28 17:42:44 -06:00
|
|
|
dirs.each do |dir|
|
2013-09-27 11:45:55 +01:00
|
|
|
run_vagrant_command(test_dir_exists(dir))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^the repo is cloned$/) do
|
|
|
|
run_vagrant_command(test_dir_exists(TestApp.repo_path))
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^the release is created$/) do
|
|
|
|
run_vagrant_command("ls -g #{TestApp.releases_path}")
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^file symlinks are created in the new release$/) do
|
|
|
|
TestApp.linked_files.each do |file|
|
2014-04-26 14:30:55 +02:00
|
|
|
run_vagrant_command(test_symlink_exists(TestApp.current_path.join(file)))
|
2013-09-27 11:45:55 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^directory symlinks are created in the new release$/) do
|
|
|
|
pending
|
|
|
|
TestApp.linked_dirs.each do |dir|
|
|
|
|
run_vagrant_command(test_symlink_exists(TestApp.release_path.join(dir)))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^the current directory will be a symlink to the release$/) do
|
2017-10-12 16:40:57 -03:00
|
|
|
run_vagrant_command(exists?("e", TestApp.current_path))
|
2013-09-27 11:45:55 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^the deploy\.rb file is created$/) do
|
2016-02-28 17:16:11 -06:00
|
|
|
file = TestApp.test_app_path.join("config/deploy.rb")
|
2015-08-14 14:21:34 -07:00
|
|
|
expect(File.exist?(file)).to be true
|
2013-09-27 11:45:55 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^the default stage files are created$/) do
|
2016-02-28 17:16:11 -06:00
|
|
|
staging = TestApp.test_app_path.join("config/deploy/staging.rb")
|
|
|
|
production = TestApp.test_app_path.join("config/deploy/production.rb")
|
2015-08-14 14:21:34 -07:00
|
|
|
expect(File.exist?(staging)).to be true
|
|
|
|
expect(File.exist?(production)).to be true
|
2013-09-27 11:45:55 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^the tasks folder is created$/) do
|
2016-02-28 17:16:11 -06:00
|
|
|
path = TestApp.test_app_path.join("lib/capistrano/tasks")
|
2015-08-14 14:21:34 -07:00
|
|
|
expect(Dir.exist?(path)).to be true
|
2013-09-27 11:45:55 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^the specified stage files are created$/) do
|
2016-02-28 17:16:11 -06:00
|
|
|
qa = TestApp.test_app_path.join("config/deploy/qa.rb")
|
|
|
|
production = TestApp.test_app_path.join("config/deploy/production.rb")
|
2015-08-14 14:21:34 -07:00
|
|
|
expect(File.exist?(qa)).to be true
|
|
|
|
expect(File.exist?(production)).to be true
|
2013-09-27 11:45:55 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^it creates the file with the remote_task prerequisite$/) do
|
|
|
|
TestApp.linked_files.each do |file|
|
|
|
|
run_vagrant_command(test_file_exists(TestApp.shared_path.join(file)))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^it will not recreate the file$/) do
|
|
|
|
#
|
|
|
|
end
|
2013-10-11 17:24:37 +01:00
|
|
|
|
|
|
|
Then(/^the task is successful$/) do
|
2014-08-12 22:52:37 +04:00
|
|
|
expect(@success).to be true
|
2013-10-11 17:24:37 +01:00
|
|
|
end
|
2013-11-01 11:59:13 +00:00
|
|
|
|
2014-04-26 13:27:24 +02:00
|
|
|
Then(/^the task fails$/) do
|
2014-11-24 22:49:02 +01:00
|
|
|
expect(@success).to be_falsey
|
2014-04-26 13:27:24 +02:00
|
|
|
end
|
|
|
|
|
2013-11-01 11:59:13 +00:00
|
|
|
Then(/^the failure task will run$/) do
|
2016-02-28 17:16:11 -06:00
|
|
|
failed = TestApp.shared_path.join("failed")
|
2013-11-01 11:59:13 +00:00
|
|
|
run_vagrant_command(test_file_exists(failed))
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^the failure task will not run$/) do
|
2016-02-28 17:16:11 -06:00
|
|
|
failed = TestApp.shared_path.join("failed")
|
2014-04-22 10:36:44 -05:00
|
|
|
expect { run_vagrant_command(test_file_exists(failed)) }
|
|
|
|
.to raise_error(VagrantHelpers::VagrantSSHCommandError)
|
2013-11-01 11:59:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
When(/^an error is raised$/) do
|
2016-02-28 17:16:11 -06:00
|
|
|
error = TestApp.shared_path.join("fail")
|
2013-11-01 11:59:13 +00:00
|
|
|
run_vagrant_command(test_file_exists(error))
|
|
|
|
end
|
2014-01-18 23:18:55 +02:00
|
|
|
|
2015-02-14 11:32:42 -08:00
|
|
|
Then(/contains "([^"]*)" in the output/) do |expected|
|
2014-01-18 23:18:55 +02:00
|
|
|
expect(@output).to include(expected)
|
|
|
|
end
|
2014-12-10 01:08:48 +03:00
|
|
|
|
2015-02-14 11:32:42 -08:00
|
|
|
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|
|
2014-12-10 01:08:48 +03:00
|
|
|
expect(@output).not_to include(expected)
|
|
|
|
end
|
2017-07-05 07:32:58 +05:30
|
|
|
|
|
|
|
Then(/the current symlink points to the previous release/) do
|
|
|
|
previous_release_path = @release_paths[-2]
|
|
|
|
|
|
|
|
run_vagrant_command(symlinked?(TestApp.current_path, previous_release_path))
|
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^the current symlink points to that specific release$/) do
|
|
|
|
specific_release_path = TestApp.releases_path.join(@rollback_release)
|
|
|
|
|
|
|
|
run_vagrant_command(symlinked?(TestApp.current_path, specific_release_path))
|
|
|
|
end
|