mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Merge pull request #892 from miry/load-deploy-and-stage-tasks
Updated the loading default config tasks and stages config tasks
This commit is contained in:
commit
319e18e4e6
6 changed files with 42 additions and 4 deletions
|
@ -13,3 +13,16 @@ Feature: The path to the configuration can be changed, removing the need to
|
|||
But the configuration is in a custom location
|
||||
When I run "cap test"
|
||||
Then the task is successful
|
||||
|
||||
Scenario: Show install task with configuration in default location
|
||||
When I run "cap -T"
|
||||
Then the task is successful
|
||||
And contains "install" in the output
|
||||
|
||||
Scenario: Show install task with configuration in a custom location
|
||||
And config stage file has line "desc 'Special Task'"
|
||||
And config stage file has line "task :special_stage_task"
|
||||
But the configuration is in a custom location
|
||||
When I run "cap -T"
|
||||
Then the task is successful
|
||||
And contains "special_stage_task" in the output
|
||||
|
|
|
@ -107,3 +107,7 @@ 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
|
||||
|
|
|
@ -7,6 +7,6 @@ When(/^I run cap "(.*?)" as part of a release$/) do |task|
|
|||
end
|
||||
|
||||
When(/^I run "(.*?)"$/) do |command|
|
||||
@success = TestApp.run(command)
|
||||
@success, @output = TestApp.run(command)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ Given(/^a test app with the default configuration$/) do
|
|||
end
|
||||
|
||||
Given(/^servers with the roles app and web$/) do
|
||||
vagrant_cli_command('up')
|
||||
vagrant_cli_command('up') rescue nil
|
||||
end
|
||||
|
||||
Given(/^a required file$/) do
|
||||
|
@ -23,6 +23,10 @@ Given(/^a custom task to generate a file$/) do
|
|||
TestApp.copy_task_to_test_app('spec/support/tasks/database.rake')
|
||||
end
|
||||
|
||||
Given(/config stage file has line "(.*?)"/) do |line|
|
||||
TestApp.append_to_deploy_file(line)
|
||||
end
|
||||
|
||||
Given(/^the configuration is in a custom location$/) do
|
||||
TestApp.move_configuration_to_custom_location('app')
|
||||
end
|
||||
|
|
|
@ -38,6 +38,16 @@ module Capistrano
|
|||
|
||||
private
|
||||
|
||||
def load_imports
|
||||
if options.show_tasks
|
||||
invoke 'load:defaults'
|
||||
set(:stage, '')
|
||||
Dir[deploy_config_path, stage_definitions].each { |f| add_import f }
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
# allows the `cap install` task to load without a capfile
|
||||
def capfile
|
||||
File.expand_path(File.join(File.dirname(__FILE__),'..','Capfile'))
|
||||
|
|
|
@ -57,6 +57,12 @@ module TestApp
|
|||
end
|
||||
end
|
||||
|
||||
def append_to_deploy_file(config)
|
||||
File.open(test_stage_path, 'a') do |file|
|
||||
file.write config + "\n"
|
||||
end
|
||||
end
|
||||
|
||||
def prepend_to_capfile(config)
|
||||
current_capfile = File.read(capfile)
|
||||
File.open(capfile, 'w') do |file|
|
||||
|
@ -78,10 +84,11 @@ module TestApp
|
|||
end
|
||||
|
||||
def run(command)
|
||||
output = nil
|
||||
Dir.chdir(test_app_path) do
|
||||
%x[#{command}]
|
||||
output = %x[#{command}]
|
||||
end
|
||||
$?.success?
|
||||
[$?.success?, output]
|
||||
end
|
||||
|
||||
def stage
|
||||
|
|
Loading…
Reference in a new issue