capistrano 2.15.11 → 3.0.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +17 -8
- data/Gemfile +1 -12
- data/LICENSE.txt +18 -0
- data/README.md +65 -68
- data/Rakefile +4 -10
- data/bin/cap +2 -3
- data/bin/capify +7 -91
- data/capistrano.gemspec +20 -34
- data/lib/Capfile +2 -0
- data/lib/capistrano/application.rb +28 -0
- data/lib/capistrano/bundler.rb +1 -0
- data/lib/capistrano/configuration/question.rb +42 -0
- data/lib/capistrano/configuration/server.rb +24 -0
- data/lib/capistrano/configuration/servers.rb +43 -95
- data/lib/capistrano/configuration.rb +81 -44
- data/lib/capistrano/console.rb +1 -0
- data/lib/capistrano/defaults.rb +11 -0
- data/lib/capistrano/deploy.rb +3 -0
- data/lib/capistrano/dotfile.rb +3 -0
- data/lib/capistrano/dsl/env.rb +57 -0
- data/lib/capistrano/dsl/paths.rb +74 -0
- data/lib/capistrano/dsl/stages.rb +15 -0
- data/lib/capistrano/dsl/task_enhancements.rb +15 -0
- data/lib/capistrano/dsl.rb +38 -0
- data/lib/capistrano/git.rb +1 -0
- data/lib/capistrano/i18n.rb +33 -0
- data/lib/capistrano/install.rb +1 -0
- data/lib/capistrano/setup.rb +17 -0
- data/lib/capistrano/tasks/bundler.rake +13 -0
- data/lib/capistrano/tasks/console.rake +21 -0
- data/lib/capistrano/tasks/deploy.rake +153 -0
- data/lib/capistrano/tasks/framework.rake +45 -0
- data/lib/capistrano/tasks/git.rake +65 -0
- data/lib/capistrano/tasks/install.rake +39 -0
- data/lib/capistrano/templates/Capfile +43 -0
- data/lib/capistrano/templates/deploy.rb.erb +17 -0
- data/lib/capistrano/templates/stage.rb.erb +20 -0
- data/lib/capistrano/version.rb +1 -11
- data/lib/capistrano.rb +9 -3
- data/spec/lib/capistrano/configuration/question_spec.rb +54 -0
- data/spec/lib/capistrano/configuration/server_spec.rb +48 -0
- data/spec/lib/capistrano/configuration/servers_spec.rb +79 -0
- data/spec/lib/capistrano/configuration_spec.rb +80 -0
- data/spec/lib/capistrano/dsl/env_spec.rb +83 -0
- data/spec/lib/capistrano/dsl/paths_spec.rb +69 -0
- data/spec/lib/capistrano/dsl_spec.rb +51 -0
- data/spec/lib/capistrano_spec.rb +8 -0
- data/spec/spec_helper.rb +14 -0
- metadata +89 -215
- data/.travis.yml +0 -9
- data/CHANGELOG +0 -1203
- data/lib/capistrano/callback.rb +0 -45
- data/lib/capistrano/cli/execute.rb +0 -85
- data/lib/capistrano/cli/help.rb +0 -125
- data/lib/capistrano/cli/help.txt +0 -81
- data/lib/capistrano/cli/options.rb +0 -243
- data/lib/capistrano/cli/ui.rb +0 -40
- data/lib/capistrano/cli.rb +0 -47
- data/lib/capistrano/command.rb +0 -303
- data/lib/capistrano/configuration/actions/file_transfer.rb +0 -50
- data/lib/capistrano/configuration/actions/inspect.rb +0 -46
- data/lib/capistrano/configuration/actions/invocation.rb +0 -329
- data/lib/capistrano/configuration/alias_task.rb +0 -26
- data/lib/capistrano/configuration/callbacks.rb +0 -147
- data/lib/capistrano/configuration/connections.rb +0 -237
- data/lib/capistrano/configuration/execution.rb +0 -142
- data/lib/capistrano/configuration/loading.rb +0 -205
- data/lib/capistrano/configuration/log_formatters.rb +0 -75
- data/lib/capistrano/configuration/namespaces.rb +0 -223
- data/lib/capistrano/configuration/roles.rb +0 -83
- data/lib/capistrano/configuration/variables.rb +0 -127
- data/lib/capistrano/errors.rb +0 -19
- data/lib/capistrano/ext/multistage.rb +0 -67
- data/lib/capistrano/ext/string.rb +0 -5
- data/lib/capistrano/extensions.rb +0 -57
- data/lib/capistrano/fix_rake_deprecated_dsl.rb +0 -8
- data/lib/capistrano/logger.rb +0 -166
- data/lib/capistrano/processable.rb +0 -55
- data/lib/capistrano/recipes/compat.rb +0 -32
- data/lib/capistrano/recipes/deploy/assets.rb +0 -202
- data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
- data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -54
- data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -117
- data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
- data/lib/capistrano/recipes/deploy/scm/base.rb +0 -200
- data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
- data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -153
- data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -96
- data/lib/capistrano/recipes/deploy/scm/git.rb +0 -299
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
- data/lib/capistrano/recipes/deploy/scm/none.rb +0 -55
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -152
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -121
- data/lib/capistrano/recipes/deploy/scm.rb +0 -19
- data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -92
- data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -338
- data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
- data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -57
- data/lib/capistrano/recipes/deploy/strategy/unshared_remote_cache.rb +0 -21
- data/lib/capistrano/recipes/deploy/strategy.rb +0 -20
- data/lib/capistrano/recipes/deploy.rb +0 -625
- data/lib/capistrano/recipes/standard.rb +0 -37
- data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/role.rb +0 -102
- data/lib/capistrano/server_definition.rb +0 -56
- data/lib/capistrano/shell.rb +0 -265
- data/lib/capistrano/ssh.rb +0 -95
- data/lib/capistrano/task_definition.rb +0 -77
- data/lib/capistrano/transfer.rb +0 -218
- data/test/cli/execute_test.rb +0 -132
- data/test/cli/help_test.rb +0 -165
- data/test/cli/options_test.rb +0 -329
- data/test/cli/ui_test.rb +0 -28
- data/test/cli_test.rb +0 -17
- data/test/command_test.rb +0 -322
- data/test/configuration/actions/file_transfer_test.rb +0 -61
- data/test/configuration/actions/inspect_test.rb +0 -76
- data/test/configuration/actions/invocation_test.rb +0 -306
- data/test/configuration/alias_task_test.rb +0 -118
- data/test/configuration/callbacks_test.rb +0 -201
- data/test/configuration/connections_test.rb +0 -439
- data/test/configuration/execution_test.rb +0 -175
- data/test/configuration/loading_test.rb +0 -148
- data/test/configuration/namespace_dsl_test.rb +0 -332
- data/test/configuration/roles_test.rb +0 -157
- data/test/configuration/servers_test.rb +0 -183
- data/test/configuration/variables_test.rb +0 -190
- data/test/configuration_test.rb +0 -77
- data/test/deploy/local_dependency_test.rb +0 -76
- data/test/deploy/remote_dependency_test.rb +0 -146
- data/test/deploy/scm/accurev_test.rb +0 -23
- data/test/deploy/scm/base_test.rb +0 -55
- data/test/deploy/scm/bzr_test.rb +0 -51
- data/test/deploy/scm/darcs_test.rb +0 -37
- data/test/deploy/scm/git_test.rb +0 -274
- data/test/deploy/scm/mercurial_test.rb +0 -134
- data/test/deploy/scm/none_test.rb +0 -35
- data/test/deploy/scm/perforce_test.rb +0 -23
- data/test/deploy/scm/subversion_test.rb +0 -68
- data/test/deploy/strategy/copy_test.rb +0 -360
- data/test/extensions_test.rb +0 -69
- data/test/fixtures/cli_integration.rb +0 -5
- data/test/fixtures/config.rb +0 -5
- data/test/fixtures/custom.rb +0 -3
- data/test/logger_formatting_test.rb +0 -149
- data/test/logger_test.rb +0 -134
- data/test/recipes_test.rb +0 -25
- data/test/role_test.rb +0 -11
- data/test/server_definition_test.rb +0 -121
- data/test/shell_test.rb +0 -96
- data/test/ssh_test.rb +0 -113
- data/test/task_definition_test.rb +0 -117
- data/test/transfer_test.rb +0 -168
- data/test/utils.rb +0 -37
- data/test/version_test.rb +0 -11
data/test/extensions_test.rb
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
require "utils"
|
|
2
|
-
require 'capistrano'
|
|
3
|
-
|
|
4
|
-
class ExtensionsTest < Test::Unit::TestCase
|
|
5
|
-
module CustomExtension
|
|
6
|
-
def do_something(command)
|
|
7
|
-
run(command)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def setup
|
|
12
|
-
@config = Capistrano::Configuration.new
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def teardown
|
|
16
|
-
Capistrano::EXTENSIONS.keys.each { |e| Capistrano.remove_plugin(e) }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_register_plugin_should_add_instance_method_on_configuration_and_return_true
|
|
20
|
-
assert !@config.respond_to?(:custom_stuff)
|
|
21
|
-
assert Capistrano.plugin(:custom_stuff, CustomExtension)
|
|
22
|
-
assert @config.respond_to?(:custom_stuff)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def test_register_plugin_that_already_exists_should_return_false
|
|
26
|
-
assert Capistrano.plugin(:custom_stuff, CustomExtension)
|
|
27
|
-
assert !Capistrano.plugin(:custom_stuff, CustomExtension)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def test_register_plugin_with_public_method_name_should_fail
|
|
31
|
-
method = Capistrano::Configuration.public_instance_methods.first
|
|
32
|
-
assert_not_nil method, "need a public instance method for testing"
|
|
33
|
-
assert_raises(Capistrano::Error) { Capistrano.plugin(method, CustomExtension) }
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def test_register_plugin_with_protected_method_name_should_fail
|
|
37
|
-
method = Capistrano::Configuration.protected_instance_methods.first
|
|
38
|
-
assert_not_nil method, "need a protected instance method for testing"
|
|
39
|
-
assert_raises(Capistrano::Error) { Capistrano.plugin(method, CustomExtension) }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def test_register_plugin_with_private_method_name_should_fail
|
|
43
|
-
method = Capistrano::Configuration.private_instance_methods.first
|
|
44
|
-
assert_not_nil method, "need a private instance method for testing"
|
|
45
|
-
assert_raises(Capistrano::Error) { Capistrano.plugin(method, CustomExtension) }
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def test_unregister_plugin_that_does_not_exist_should_return_false
|
|
49
|
-
assert !Capistrano.remove_plugin(:custom_stuff)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def test_unregister_plugin_should_remove_method_and_return_true
|
|
53
|
-
assert Capistrano.plugin(:custom_stuff, CustomExtension)
|
|
54
|
-
assert @config.respond_to?(:custom_stuff)
|
|
55
|
-
assert Capistrano.remove_plugin(:custom_stuff)
|
|
56
|
-
assert !@config.respond_to?(:custom_stuff)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def test_registered_plugin_proxy_should_return_proxy_object
|
|
60
|
-
Capistrano.plugin(:custom_stuff, CustomExtension)
|
|
61
|
-
assert_instance_of Capistrano::ExtensionProxy, @config.custom_stuff
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def test_proxy_object_should_delegate_to_configuration
|
|
65
|
-
Capistrano.plugin(:custom_stuff, CustomExtension)
|
|
66
|
-
@config.expects(:run).with("hello")
|
|
67
|
-
@config.custom_stuff.do_something("hello")
|
|
68
|
-
end
|
|
69
|
-
end
|
data/test/fixtures/config.rb
DELETED
data/test/fixtures/custom.rb
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
require File.expand_path("../utils", __FILE__)
|
|
2
|
-
require 'capistrano/logger'
|
|
3
|
-
require 'stringio'
|
|
4
|
-
|
|
5
|
-
Capistrano::Logger.class_eval do
|
|
6
|
-
# Allows formatters to be changed during tests
|
|
7
|
-
def self.formatters=(formatters)
|
|
8
|
-
@formatters = formatters
|
|
9
|
-
@sorted_formatters = nil
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
class LoggerFormattingTest < Test::Unit::TestCase
|
|
14
|
-
def setup
|
|
15
|
-
@io = StringIO.new
|
|
16
|
-
@io.stubs(:tty?).returns(true)
|
|
17
|
-
@logger = Capistrano::Logger.new(:output => @io, :level => 3)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_matching_with_style_and_color
|
|
21
|
-
Capistrano::Logger.formatters = [{ :match => /^err ::/, :color => :red, :style => :underscore, :level => 0 }]
|
|
22
|
-
@logger.log(0, "err :: Error Occurred")
|
|
23
|
-
assert @io.string.include? "\e[4;31merr :: Error Occurred\e[0m"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_style_without_color
|
|
27
|
-
Capistrano::Logger.formatters = [{ :match => /.*/, :style => :underscore, :level => 0 }]
|
|
28
|
-
@logger.log(0, "test message")
|
|
29
|
-
# Default color should be blank (0m)
|
|
30
|
-
assert @io.string.include? "\e[4;0mtest message\e[0m"
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def test_prepending_text
|
|
34
|
-
Capistrano::Logger.formatters = [{ :match => /^executing/, :level => 0, :prepend => '== Currently ' }]
|
|
35
|
-
@logger.log(0, "executing task")
|
|
36
|
-
assert @io.string.include? '== Currently executing task'
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def test_replacing_matched_text
|
|
40
|
-
Capistrano::Logger.formatters = [{ :match => /^executing/, :level => 0, :replace => 'running' }]
|
|
41
|
-
@logger.log(0, "executing task")
|
|
42
|
-
assert @io.string.include? 'running task'
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def test_prepending_timestamps
|
|
46
|
-
Capistrano::Logger.formatters = [{ :match => /.*/, :level => 0, :timestamp => true }]
|
|
47
|
-
@logger.log(0, "test message")
|
|
48
|
-
assert @io.string.match /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} test message/
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def test_formatter_priorities
|
|
52
|
-
Capistrano::Logger.formatters = [
|
|
53
|
-
{ :match => /.*/, :color => :red, :level => 0, :priority => -10 },
|
|
54
|
-
{ :match => /.*/, :color => :blue, :level => 0, :priority => -20, :prepend => '###' }
|
|
55
|
-
]
|
|
56
|
-
|
|
57
|
-
@logger.log(0, "test message")
|
|
58
|
-
# Only the red formatter (color 31) should be applied.
|
|
59
|
-
assert @io.string.include? "\e[31mtest message"
|
|
60
|
-
# The blue formatter should not have prepended $$$
|
|
61
|
-
assert !@io.string.include?('###')
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def test_no_formatting_if_no_color_or_style
|
|
65
|
-
Capistrano::Logger.formatters = []
|
|
66
|
-
@logger.log(0, "test message")
|
|
67
|
-
assert @io.string.include? "*** test message"
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def test_formatter_log_levels
|
|
71
|
-
Capistrano::Logger.formatters = [{ :match => /.*/, :color => :blue, :level => 3 }]
|
|
72
|
-
@logger.log(0, "test message")
|
|
73
|
-
# Should not match log level
|
|
74
|
-
assert @io.string.include? "*** test message"
|
|
75
|
-
|
|
76
|
-
clear_logger
|
|
77
|
-
@logger.log(3, "test message")
|
|
78
|
-
# Should match log level and apply blue color
|
|
79
|
-
assert @io.string.include? "\e[34mtest message"
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
private
|
|
83
|
-
|
|
84
|
-
def colorize(message, color, style = nil)
|
|
85
|
-
style = "#{style};" if style
|
|
86
|
-
"\e[#{style}#{color}m" + message + "\e[0m"
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def clear_logger
|
|
90
|
-
@io = StringIO.new
|
|
91
|
-
@io.stubs(:tty?).returns(true)
|
|
92
|
-
@logger.device = @io
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
class DefaultLoggerFormattersTest < Test::Unit::TestCase
|
|
97
|
-
def setup
|
|
98
|
-
@expected_default_formatter_values = [
|
|
99
|
-
# TRACE
|
|
100
|
-
{ :match => /command finished/, :color => :white, :style => :dim, :level => 3, :priority => -10 },
|
|
101
|
-
{ :match => /executing locally/, :color => :yellow, :level => 3, :priority => -20 },
|
|
102
|
-
|
|
103
|
-
# DEBUG
|
|
104
|
-
{ :match => /executing `.*/, :color => :green, :level => 2, :priority => -10, :timestamp => true },
|
|
105
|
-
{ :match => /.*/, :color => :yellow, :level => 2, :priority => -30 },
|
|
106
|
-
|
|
107
|
-
# INFO
|
|
108
|
-
{ :match => /.*out\] (fatal:|ERROR:).*/, :color => :red, :level => 1, :priority => -10 },
|
|
109
|
-
{ :match => /Permission denied/, :color => :red, :level => 1, :priority => -20 },
|
|
110
|
-
{ :match => /sh: .+: command not found/, :color => :magenta, :level => 1, :priority => -30 },
|
|
111
|
-
|
|
112
|
-
# IMPORTANT
|
|
113
|
-
{ :match => /^err ::/, :color => :red, :level => 0, :priority => -10 },
|
|
114
|
-
{ :match => /.*/, :color => :blue, :level => 0, :priority => -20 }
|
|
115
|
-
]
|
|
116
|
-
|
|
117
|
-
@custom_default_formatter_values = [
|
|
118
|
-
{ :match => /.*/, :color => :white }
|
|
119
|
-
]
|
|
120
|
-
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def test_default_formatters_api
|
|
124
|
-
assert Capistrano::Logger.respond_to? :default_formatters
|
|
125
|
-
assert Capistrano::Logger.respond_to? :default_formatters=
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def test_default_formatters_values
|
|
129
|
-
assert_equal @expected_default_formatter_values, Capistrano::Logger.default_formatters
|
|
130
|
-
assert_equal @expected_default_formatter_values, Capistrano::Logger.instance_variable_get("@formatters")
|
|
131
|
-
assert_equal nil, Capistrano::Logger.instance_variable_get("@sorted_formatters")
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def test_set_default_formatters_values
|
|
135
|
-
# when given an array
|
|
136
|
-
Capistrano::Logger.default_formatters = @custom_default_formatter_values
|
|
137
|
-
|
|
138
|
-
assert_equal @custom_default_formatter_values, Capistrano::Logger.default_formatters
|
|
139
|
-
Capistrano::Logger.default_formatters = @custom_default_formatter_values
|
|
140
|
-
assert_equal @custom_default_formatter_values, Capistrano::Logger.instance_variable_get("@formatters")
|
|
141
|
-
assert_equal nil, Capistrano::Logger.instance_variable_get("@sorted_formatters")
|
|
142
|
-
|
|
143
|
-
# when given a single formatter values hash
|
|
144
|
-
Capistrano::Logger.default_formatters = @custom_default_formatter_values.first
|
|
145
|
-
|
|
146
|
-
assert_equal @custom_default_formatter_values, Capistrano::Logger.default_formatters
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
end
|
data/test/logger_test.rb
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
require "utils"
|
|
2
|
-
require 'capistrano/logger'
|
|
3
|
-
require 'stringio'
|
|
4
|
-
|
|
5
|
-
class LoggerTest < Test::Unit::TestCase
|
|
6
|
-
def setup
|
|
7
|
-
@io = StringIO.new
|
|
8
|
-
# Turn off formatting for these tests. Formatting is tested in `logger_formatting_test.rb`.
|
|
9
|
-
@logger = Capistrano::Logger.new(:output => @io, :disable_formatters => true)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def test_logger_should_use_STDERR_by_default
|
|
13
|
-
logger = Capistrano::Logger.new
|
|
14
|
-
assert_equal STDERR, logger.device
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def test_logger_should_have_log_level_0
|
|
18
|
-
logger = Capistrano::Logger.new
|
|
19
|
-
assert_equal 0, logger.level
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def test_logger_should_use_level_form_options
|
|
23
|
-
logger = Capistrano::Logger.new :level => 4
|
|
24
|
-
assert_equal 4, logger.level
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def test_logger_should_use_output_option_if_output_responds_to_puts
|
|
28
|
-
logger = Capistrano::Logger.new(:output => STDOUT)
|
|
29
|
-
assert_equal STDOUT, logger.device
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_logger_should_open_file_if_output_does_not_respond_to_puts
|
|
33
|
-
File.expects(:open).with("logs/capistrano.log", "a").returns(:mock)
|
|
34
|
-
logger = Capistrano::Logger.new(:output => "logs/capistrano.log")
|
|
35
|
-
assert_equal :mock, logger.device
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def test_close_should_not_close_device_if_device_is_default
|
|
39
|
-
logger = Capistrano::Logger.new
|
|
40
|
-
logger.device.expects(:close).never
|
|
41
|
-
logger.close
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def test_close_should_not_close_device_is_device_is_explicitly_given
|
|
45
|
-
logger = Capistrano::Logger.new(:output => STDOUT)
|
|
46
|
-
STDOUT.expects(:close).never
|
|
47
|
-
logger.close
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def test_close_should_close_device_when_device_was_implicitly_opened
|
|
51
|
-
f = mock("file", :close => nil)
|
|
52
|
-
File.expects(:open).with("logs/capistrano.log", "a").returns(f)
|
|
53
|
-
logger = Capistrano::Logger.new(:output => "logs/capistrano.log")
|
|
54
|
-
logger.close
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def test_log_with_level_greater_than_threshold_should_ignore_message
|
|
58
|
-
@logger.level = 3
|
|
59
|
-
@logger.log(4, "message")
|
|
60
|
-
assert @io.string.empty?
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def test_log_with_level_equal_to_threshold_should_log_message
|
|
64
|
-
@logger.level = 3
|
|
65
|
-
@logger.log(3, "message")
|
|
66
|
-
assert @io.string.include?("message")
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def test_log_with_level_less_than_threshold_should_log_message
|
|
70
|
-
@logger.level = 3
|
|
71
|
-
@logger.log(2, "message")
|
|
72
|
-
assert @io.string.include?("message")
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def test_log_with_multiline_message_should_log_each_line_separately
|
|
76
|
-
@logger.log(0, "first line\nsecond line")
|
|
77
|
-
assert @io.string.include?("*** first line")
|
|
78
|
-
assert @io.string.include?("*** second line")
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def test_log_with_line_prefix_should_insert_line_prefix_before_message
|
|
82
|
-
@logger.log(0, "message", "prefix")
|
|
83
|
-
assert @io.string.include?("*** [prefix] message")
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def test_log_with_level_0_should_have_strong_indent
|
|
87
|
-
@logger.log(0, "message")
|
|
88
|
-
assert @io.string.match(/^\*\*\* message/)
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def test_log_with_level_1_should_have_weaker_indent
|
|
92
|
-
@logger.level = 1
|
|
93
|
-
@logger.log(1, "message")
|
|
94
|
-
assert @io.string.match(/^ \*\* message/)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def test_log_with_level_2_should_have_weaker_indent
|
|
98
|
-
@logger.level = 2
|
|
99
|
-
@logger.log(2, "message")
|
|
100
|
-
assert @io.string.match(/^ \* message/)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def test_log_with_level_3_should_have_weakest_indent
|
|
104
|
-
@logger.level = 3
|
|
105
|
-
@logger.log(3, "message")
|
|
106
|
-
assert @io.string.match(/^ message/)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def test_important_should_delegate_to_log_with_level_IMPORTANT
|
|
110
|
-
@logger.expects(:log).with(Capistrano::Logger::IMPORTANT, "message", "prefix")
|
|
111
|
-
@logger.important("message", "prefix")
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def test_info_should_delegate_to_log_with_level_INFO
|
|
115
|
-
@logger.expects(:log).with(Capistrano::Logger::INFO, "message", "prefix")
|
|
116
|
-
@logger.info("message", "prefix")
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def test_debug_should_delegate_to_log_with_level_DEBUG
|
|
120
|
-
@logger.expects(:log).with(Capistrano::Logger::DEBUG, "message", "prefix")
|
|
121
|
-
@logger.debug("message", "prefix")
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
def test_trace_should_delegate_to_log_with_level_TRACE
|
|
125
|
-
@logger.expects(:log).with(Capistrano::Logger::TRACE, "message", "prefix")
|
|
126
|
-
@logger.trace("message", "prefix")
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def test_ordering_of_levels
|
|
130
|
-
assert Capistrano::Logger::IMPORTANT < Capistrano::Logger::INFO
|
|
131
|
-
assert Capistrano::Logger::INFO < Capistrano::Logger::DEBUG
|
|
132
|
-
assert Capistrano::Logger::DEBUG < Capistrano::Logger::TRACE
|
|
133
|
-
end
|
|
134
|
-
end
|
data/test/recipes_test.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require 'utils'
|
|
2
|
-
require 'capistrano/configuration'
|
|
3
|
-
|
|
4
|
-
class RecipesTest < Test::Unit::TestCase
|
|
5
|
-
|
|
6
|
-
def setup
|
|
7
|
-
@config = Capistrano::Configuration.new
|
|
8
|
-
@config.stubs(:logger).returns(stub_everything)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def test_current_releases_does_not_cause_error_on_dry_run
|
|
12
|
-
@config.dry_run = true
|
|
13
|
-
@config.load 'deploy'
|
|
14
|
-
@config.load do
|
|
15
|
-
set :application, "foo"
|
|
16
|
-
task :dry_run_test do
|
|
17
|
-
fetch :current_release
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
assert_nothing_raised do
|
|
22
|
-
@config.dry_run_test
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
data/test/role_test.rb
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require "utils"
|
|
2
|
-
require 'capistrano/role'
|
|
3
|
-
|
|
4
|
-
class RoleTest < Test::Unit::TestCase
|
|
5
|
-
def test_clearing_a_populated_role_should_yield_no_servers
|
|
6
|
-
role = Capistrano::Role.new("app1.capistrano.test", lambda { |o| "app2.capistrano.test" })
|
|
7
|
-
assert_equal 2, role.servers.size
|
|
8
|
-
role.clear
|
|
9
|
-
assert role.servers.empty?
|
|
10
|
-
end
|
|
11
|
-
end
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
require "utils"
|
|
2
|
-
require 'capistrano/server_definition'
|
|
3
|
-
|
|
4
|
-
class ServerDefinitionTest < Test::Unit::TestCase
|
|
5
|
-
def test_new_without_credentials_or_port_should_set_values_to_defaults
|
|
6
|
-
server = Capistrano::ServerDefinition.new("www.capistrano.test")
|
|
7
|
-
assert_equal "www.capistrano.test", server.host
|
|
8
|
-
assert_nil server.user
|
|
9
|
-
assert_nil server.port
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def test_new_with_encoded_user_should_extract_user_and_use_default_port
|
|
13
|
-
server = Capistrano::ServerDefinition.new("jamis@www.capistrano.test")
|
|
14
|
-
assert_equal "www.capistrano.test", server.host
|
|
15
|
-
assert_equal "jamis", server.user
|
|
16
|
-
assert_nil server.port
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_new_with_encoded_port_should_extract_port_and_use_default_user
|
|
20
|
-
server = Capistrano::ServerDefinition.new("www.capistrano.test:8080")
|
|
21
|
-
assert_equal "www.capistrano.test", server.host
|
|
22
|
-
assert_nil server.user
|
|
23
|
-
assert_equal 8080, server.port
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_new_with_encoded_user_and_port_should_extract_user_and_port
|
|
27
|
-
server = Capistrano::ServerDefinition.new("jamis@www.capistrano.test:8080")
|
|
28
|
-
assert_equal "www.capistrano.test", server.host
|
|
29
|
-
assert_equal "jamis", server.user
|
|
30
|
-
assert_equal 8080, server.port
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def test_new_with_user_as_option_should_use_given_user
|
|
34
|
-
server = Capistrano::ServerDefinition.new("www.capistrano.test", :user => "jamis")
|
|
35
|
-
assert_equal "www.capistrano.test", server.host
|
|
36
|
-
assert_equal "jamis", server.user
|
|
37
|
-
assert_nil server.port
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def test_new_with_port_as_option_should_use_given_user
|
|
41
|
-
server = Capistrano::ServerDefinition.new("www.capistrano.test", :port => 8080)
|
|
42
|
-
assert_equal "www.capistrano.test", server.host
|
|
43
|
-
assert_nil server.user
|
|
44
|
-
assert_equal 8080, server.port
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def test_encoded_value_should_override_hash_option
|
|
48
|
-
server = Capistrano::ServerDefinition.new("jamis@www.capistrano.test:8080", :user => "david", :port => 8081)
|
|
49
|
-
assert_equal "www.capistrano.test", server.host
|
|
50
|
-
assert_equal "jamis", server.user
|
|
51
|
-
assert_equal 8080, server.port
|
|
52
|
-
assert server.options.empty?
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def test_new_with_option_should_dup_option_hash
|
|
56
|
-
options = {}
|
|
57
|
-
server = Capistrano::ServerDefinition.new("www.capistrano.test", options)
|
|
58
|
-
assert_not_equal options.object_id, server.options.object_id
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def test_new_with_options_should_keep_options
|
|
62
|
-
server = Capistrano::ServerDefinition.new("www.capistrano.test", :primary => true)
|
|
63
|
-
assert_equal true, server.options[:primary]
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def test_default_user_should_try_to_guess_username
|
|
67
|
-
ENV.stubs(:[]).returns(nil)
|
|
68
|
-
assert_equal "not-specified", Capistrano::ServerDefinition.default_user
|
|
69
|
-
|
|
70
|
-
ENV.stubs(:[]).returns(nil)
|
|
71
|
-
ENV.stubs(:[]).with("USERNAME").returns("ryan")
|
|
72
|
-
assert_equal "ryan", Capistrano::ServerDefinition.default_user
|
|
73
|
-
|
|
74
|
-
ENV.stubs(:[]).returns(nil)
|
|
75
|
-
ENV.stubs(:[]).with("USER").returns("jamis")
|
|
76
|
-
assert_equal "jamis", Capistrano::ServerDefinition.default_user
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def test_comparison_should_match_when_host_user_port_are_same
|
|
80
|
-
s1 = server("jamis@www.capistrano.test:8080")
|
|
81
|
-
s2 = server("www.capistrano.test", :user => "jamis", :port => 8080)
|
|
82
|
-
assert_equal s1, s2
|
|
83
|
-
assert_equal s1.hash, s2.hash
|
|
84
|
-
assert s1.eql?(s2)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def test_servers_should_be_comparable
|
|
88
|
-
s1 = server("jamis@www.capistrano.test:8080")
|
|
89
|
-
s2 = server("www.alphabet.test:1234")
|
|
90
|
-
s3 = server("jamis@www.capistrano.test:8075")
|
|
91
|
-
s4 = server("billy@www.capistrano.test:8080")
|
|
92
|
-
|
|
93
|
-
assert s2 < s1
|
|
94
|
-
assert s3 < s1
|
|
95
|
-
assert s4 < s1
|
|
96
|
-
assert s2 < s3
|
|
97
|
-
assert s2 < s4
|
|
98
|
-
assert s3 < s4
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def test_comparison_should_not_match_when_any_of_host_user_port_differ
|
|
102
|
-
s1 = server("jamis@www.capistrano.test:8080")
|
|
103
|
-
s2 = server("bob@www.capistrano.test:8080")
|
|
104
|
-
s3 = server("jamis@www.capistrano.test:8081")
|
|
105
|
-
s4 = server("jamis@app.capistrano.test:8080")
|
|
106
|
-
assert_not_equal s1, s2
|
|
107
|
-
assert_not_equal s1, s3
|
|
108
|
-
assert_not_equal s1, s4
|
|
109
|
-
assert_not_equal s2, s3
|
|
110
|
-
assert_not_equal s2, s4
|
|
111
|
-
assert_not_equal s3, s4
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def test_to_s
|
|
115
|
-
assert_equal "www.capistrano.test", server("www.capistrano.test").to_s
|
|
116
|
-
assert_equal "www.capistrano.test", server("www.capistrano.test:22").to_s
|
|
117
|
-
assert_equal "www.capistrano.test:1234", server("www.capistrano.test:1234").to_s
|
|
118
|
-
assert_equal "jamis@www.capistrano.test", server("jamis@www.capistrano.test").to_s
|
|
119
|
-
assert_equal "jamis@www.capistrano.test:1234", server("jamis@www.capistrano.test:1234").to_s
|
|
120
|
-
end
|
|
121
|
-
end
|
data/test/shell_test.rb
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
require "utils"
|
|
2
|
-
require 'capistrano/configuration'
|
|
3
|
-
require 'capistrano/shell'
|
|
4
|
-
|
|
5
|
-
class ShellTest < Test::Unit::TestCase
|
|
6
|
-
def setup
|
|
7
|
-
@config = Capistrano::Configuration.new
|
|
8
|
-
@shell = Capistrano::Shell.new(@config)
|
|
9
|
-
@shell.stubs(:puts)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def test_readline_fallback_prompt_should_write_to_stdout_and_read_from_stdin
|
|
13
|
-
STDOUT.expects(:print).with("prompt> ")
|
|
14
|
-
STDOUT.expects(:flush)
|
|
15
|
-
STDIN.expects(:gets).returns("hi\n")
|
|
16
|
-
assert_equal "hi\n", Capistrano::Shell::ReadlineFallback.readline("prompt> ")
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_question_mark_as_input_should_trigger_help
|
|
20
|
-
@shell.expects(:read_line).returns("?")
|
|
21
|
-
@shell.expects(:help)
|
|
22
|
-
assert @shell.read_and_execute
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def test_help_as_input_should_trigger_help
|
|
26
|
-
@shell.expects(:read_line).returns("help")
|
|
27
|
-
@shell.expects(:help)
|
|
28
|
-
assert @shell.read_and_execute
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def test_quit_as_input_should_cause_read_and_execute_to_return_false
|
|
32
|
-
@shell.expects(:read_line).returns("quit")
|
|
33
|
-
assert !@shell.read_and_execute
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def test_exit_as_input_should_cause_read_and_execute_to_return_false
|
|
37
|
-
@shell.expects(:read_line).returns("exit")
|
|
38
|
-
assert !@shell.read_and_execute
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def test_set_should_parse_flag_and_value_and_call_set_option
|
|
42
|
-
@shell.expects(:read_line).returns("set -v 5")
|
|
43
|
-
@shell.expects(:set_option).with("v", "5")
|
|
44
|
-
assert @shell.read_and_execute
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def test_set_with_colon_changes_setting
|
|
48
|
-
@shell.expects(:read_line).returns("set :random_setting value")
|
|
49
|
-
@shell.configuration.expects(:set).with(:random_setting, "value")
|
|
50
|
-
assert @shell.read_and_execute
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def test_text_without_with_or_on_gets_processed_verbatim
|
|
54
|
-
@shell.expects(:read_line).returns("hello world")
|
|
55
|
-
@shell.expects(:process_command).with(nil, nil, "hello world")
|
|
56
|
-
assert @shell.read_and_execute
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def test_text_with_with_gets_processed_with_with # lol
|
|
60
|
-
@shell.expects(:read_line).returns("with app,db hello world")
|
|
61
|
-
@shell.expects(:process_command).with("with", "app,db", "hello world")
|
|
62
|
-
assert @shell.read_and_execute
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def test_text_with_on_gets_processed_with_on
|
|
66
|
-
@shell.expects(:read_line).returns("on app,db hello world")
|
|
67
|
-
@shell.expects(:process_command).with("on", "app,db", "hello world")
|
|
68
|
-
assert @shell.read_and_execute
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def test_task_command_with_bang_gets_processed_by_exec_tasks
|
|
72
|
-
while_testing_post_exec_commands do
|
|
73
|
-
@shell.expects(:read_line).returns("!deploy")
|
|
74
|
-
@shell.expects(:exec_tasks).with(["deploy"])
|
|
75
|
-
assert @shell.read_and_execute
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def test_normal_command_gets_processed_by_exec_command
|
|
80
|
-
while_testing_post_exec_commands do
|
|
81
|
-
@shell.expects(:read_line).returns("uptime")
|
|
82
|
-
@shell.expects(:exec_command).with("uptime",nil)
|
|
83
|
-
@shell.expects(:connect)
|
|
84
|
-
assert @shell.read_and_execute
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
private
|
|
90
|
-
|
|
91
|
-
def while_testing_post_exec_commands(&block)
|
|
92
|
-
@shell.instance_variable_set(:@mutex,Mutex.new)
|
|
93
|
-
yield
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
end
|