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

🐼 Updated the loading default config tasks and stages config tasks.

To show all tasks decalred in default config and stages files was missed from the tasks list.
Added default value for :stage and load all default configs. Also added cucumber tests.
This commit is contained in:
Michael Nikitochkin 2014-01-18 23:18:55 +02:00
parent 1f86d32fd4
commit 816b137930
6 changed files with 42 additions and 4 deletions

View file

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

View file

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

View file

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

View file

@ -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.cap')
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

View file

@ -42,6 +42,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'))

View file

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