mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
2e13a1319c
This removes the dependency on the `kuroko` gem and uses the Vagrant command line application to control the virtual environment. The `vagrant` command should be in your path, but if it isn't the path can be set with the `VAGRANT_BIN` environment variable. This may even work on older versions of Vagrant, but they are untested. The `VagrantHelpers` module was added to mimic some of the API that was provided by `kuroko`. The `RemoteCommandHelpers` module was modified to accommodate those changes. Any non-zero exit status on a remote command will raise a `VagrantHelpers::VagrantSSHCommandError` and should be expected by any tests using the command helpers. All existing tests work as expected. In addition, a couple of minor changes were made. The TestApp utilizes the Pathname library but does not require it. This was causing the suite to fail for me so I added an explicit require. Also, the test for the existence of a release directory would give a false positive on subsequent runs if the `KEEP_RUNNING` option was used. I added an `at_exit` that removes the test deployment directory to clean up the box for the next run. Documentation was also added to the README for how to run the test suites.
114 lines
3.2 KiB
Ruby
114 lines
3.2 KiB
Ruby
Then(/^references in the remote repo are listed$/) do
|
|
end
|
|
|
|
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
|
|
|
|
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 }
|
|
dirs.each do | dir|
|
|
run_vagrant_command(test_dir_exists(dir))
|
|
end
|
|
end
|
|
|
|
Then(/^the task will be successful$/) do
|
|
end
|
|
|
|
|
|
Then(/^the task will exit$/) do
|
|
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
|
|
pending
|
|
TestApp.linked_files.each do |file|
|
|
run_vagrant_command(test_symlink_exists(TestApp.release_path.join(file)))
|
|
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
|
|
run_vagrant_command(test_symlink_exists(TestApp.current_path))
|
|
end
|
|
|
|
Then(/^the deploy\.rb file is created$/) do
|
|
file = TestApp.test_app_path.join('config/deploy.rb')
|
|
expect(File.exists?(file)).to be_true
|
|
end
|
|
|
|
Then(/^the default stage files are created$/) do
|
|
staging = TestApp.test_app_path.join('config/deploy/staging.rb')
|
|
production = TestApp.test_app_path.join('config/deploy/production.rb')
|
|
expect(File.exists?(staging)).to be_true
|
|
expect(File.exists?(production)).to be_true
|
|
end
|
|
|
|
Then(/^the tasks folder is created$/) do
|
|
path = TestApp.test_app_path.join('lib/capistrano/tasks')
|
|
expect(Dir.exists?(path)).to be_true
|
|
end
|
|
|
|
Then(/^the specified stage files are created$/) do
|
|
qa = TestApp.test_app_path.join('config/deploy/qa.rb')
|
|
production = TestApp.test_app_path.join('config/deploy/production.rb')
|
|
expect(File.exists?(qa)).to be_true
|
|
expect(File.exists?(production)).to be_true
|
|
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
|
|
|
|
Then(/^the task is successful$/) do
|
|
expect(@success).to be_true
|
|
end
|
|
|
|
Then(/^the failure task will run$/) do
|
|
failed = TestApp.shared_path.join('failed')
|
|
run_vagrant_command(test_file_exists(failed))
|
|
end
|
|
|
|
Then(/^the failure task will not run$/) do
|
|
failed = TestApp.shared_path.join('failed')
|
|
expect { run_vagrant_command(test_file_exists(failed)) }
|
|
.to raise_error(VagrantHelpers::VagrantSSHCommandError)
|
|
end
|
|
|
|
When(/^an error is raised$/) do
|
|
error = TestApp.shared_path.join('fail')
|
|
run_vagrant_command(test_file_exists(error))
|
|
end
|
|
|
|
Then(/contains "(.*?)" in the output/) do |expected|
|
|
expect(@output).to include(expected)
|
|
end
|