capistrano 2.15.11 → 3.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- 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/ssh_test.rb
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
require "utils"
|
2
|
-
require 'capistrano/ssh'
|
3
|
-
|
4
|
-
class SSHTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
Capistrano::ServerDefinition.stubs(:default_user).returns("default-user")
|
7
|
-
@options = { :password => nil,
|
8
|
-
:auth_methods => %w(publickey hostbased),
|
9
|
-
:config => false }
|
10
|
-
@server = server("capistrano")
|
11
|
-
Net::SSH.stubs(:configuration_for).returns({})
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_connect_with_bare_server_without_options_or_config_with_public_key_succeeding_should_only_loop_once
|
15
|
-
Net::SSH.expects(:start).with(@server.host, "default-user", @options).returns(success = Object.new)
|
16
|
-
assert_equal success, Capistrano::SSH.connect(@server)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_connect_with_bare_server_without_options_with_public_key_failing_should_try_password
|
20
|
-
Net::SSH.expects(:start).with(@server.host, "default-user", @options).raises(Net::SSH::AuthenticationFailed)
|
21
|
-
Net::SSH.expects(:start).with(@server.host, "default-user", @options.merge(:password => "f4b13n", :auth_methods => %w(password keyboard-interactive))).returns(success = Object.new)
|
22
|
-
assert_equal success, Capistrano::SSH.connect(@server, :password => "f4b13n")
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_connect_with_bare_server_without_options_public_key_and_password_failing_should_raise_error
|
26
|
-
Net::SSH.expects(:start).with(@server.host, "default-user", @options).raises(Net::SSH::AuthenticationFailed)
|
27
|
-
Net::SSH.expects(:start).with(@server.host, "default-user", @options.merge(:password => "f4b13n", :auth_methods => %w(password keyboard-interactive))).raises(Net::SSH::AuthenticationFailed)
|
28
|
-
assert_raises(Net::SSH::AuthenticationFailed) do
|
29
|
-
Capistrano::SSH.connect(@server, :password => "f4b13n")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_connect_with_bare_server_and_user_via_public_key_should_pass_user_to_net_ssh
|
34
|
-
Net::SSH.expects(:start).with(@server.host, "jamis", @options).returns(success = Object.new)
|
35
|
-
assert_equal success, Capistrano::SSH.connect(@server, :user => "jamis")
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_connect_with_bare_server_and_user_via_password_should_pass_user_to_net_ssh
|
39
|
-
Net::SSH.expects(:start).with(@server.host, "jamis", @options).raises(Net::SSH::AuthenticationFailed)
|
40
|
-
Net::SSH.expects(:start).with(@server.host, "jamis", @options.merge(:password => "f4b13n", :auth_methods => %w(password keyboard-interactive))).returns(success = Object.new)
|
41
|
-
assert_equal success, Capistrano::SSH.connect(@server, :user => "jamis", :password => "f4b13n")
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_connect_with_bare_server_with_explicit_port_should_pass_port_to_net_ssh
|
45
|
-
Net::SSH.expects(:start).with(@server.host, "default-user", @options.merge(:port => 1234)).returns(success = Object.new)
|
46
|
-
assert_equal success, Capistrano::SSH.connect(@server, :port => 1234)
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_connect_with_server_with_user_should_pass_user_to_net_ssh
|
50
|
-
server = server("jamis@capistrano")
|
51
|
-
Net::SSH.expects(:start).with(server.host, "jamis", @options).returns(success = Object.new)
|
52
|
-
assert_equal success, Capistrano::SSH.connect(server)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_connect_with_server_with_port_should_pass_port_to_net_ssh
|
56
|
-
server = server("capistrano:1235")
|
57
|
-
Net::SSH.expects(:start).with(server.host, "default-user", @options.merge(:port => 1235)).returns(success = Object.new)
|
58
|
-
assert_equal success, Capistrano::SSH.connect(server)
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_connect_with_server_with_user_and_port_should_pass_user_and_port_to_net_ssh
|
62
|
-
server = server("jamis@capistrano:1235")
|
63
|
-
Net::SSH.expects(:start).with(server.host, "jamis", @options.merge(:port => 1235)).returns(success = Object.new)
|
64
|
-
assert_equal success, Capistrano::SSH.connect(server)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_connect_with_server_with_other_ssh_options_should_pass_ssh_options_to_net_ssh
|
68
|
-
server = server("jamis@capistrano:1235", :ssh_options => { :keys => %w(some_valid_key), :auth_methods => %w(a_method), :hmac => 'none' })
|
69
|
-
Net::SSH.expects(:start).with(server.host, "jamis", @options.merge(:port => 1235, :keys => %w(some_valid_key), :auth_methods => %w(a_method), :hmac => 'none' )).returns(success = Object.new)
|
70
|
-
assert_equal success, Capistrano::SSH.connect(server)
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_connect_with_ssh_options_should_use_ssh_options
|
74
|
-
ssh_options = { :username => "JamisMan", :port => 8125, :config => false }
|
75
|
-
Net::SSH.expects(:start).with(@server.host, "JamisMan", @options.merge(:port => 8125, :config => false)).returns(success = Object.new)
|
76
|
-
assert_equal success, Capistrano::SSH.connect(@server, {:ssh_options => ssh_options})
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_connect_with_options_and_ssh_options_should_see_options_override_ssh_options
|
80
|
-
ssh_options = { :username => "JamisMan", :port => 8125, :forward_agent => true }
|
81
|
-
Net::SSH.expects(:start).with(@server.host, "jamis", @options.merge(:port => 1235, :forward_agent => true)).returns(success = Object.new)
|
82
|
-
assert_equal success, Capistrano::SSH.connect(@server, :ssh_options => ssh_options, :user => "jamis", :port => 1235)
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_connect_with_verbose_option_should_set_verbose_option_on_ssh
|
86
|
-
Net::SSH.expects(:start).with(@server.host, "default-user", @options).returns(success = Object.new)
|
87
|
-
assert_equal success, Capistrano::SSH.connect(@server, :verbose => 0)
|
88
|
-
Net::SSH.expects(:start).with(@server.host, "default-user", @options.merge(:verbose => :debug)).returns(success = Object.new)
|
89
|
-
assert_equal success, Capistrano::SSH.connect(@server, :verbose => 1)
|
90
|
-
Net::SSH.expects(:start).with(@server.host, "default-user", @options.merge(:verbose => :debug)).returns(success = Object.new)
|
91
|
-
assert_equal success, Capistrano::SSH.connect(@server, :verbose => 2)
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_connect_with_ssh_options_should_see_server_options_override_ssh_options
|
95
|
-
ssh_options = { :username => "JamisMan", :port => 8125, :forward_agent => true }
|
96
|
-
server = server("jamis@capistrano:1235")
|
97
|
-
Net::SSH.expects(:start).with(server.host, "jamis", @options.merge(:port => 1235, :forward_agent => true, :config => false)).returns(success = Object.new)
|
98
|
-
assert_equal success, Capistrano::SSH.connect(server, {:ssh_options => ssh_options})
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_connect_should_add_xserver_accessor_to_connection
|
102
|
-
Net::SSH.expects(:start).with(@server.host, "default-user", @options).returns(success = Object.new)
|
103
|
-
assert_equal success, Capistrano::SSH.connect(@server)
|
104
|
-
assert success.respond_to?(:xserver)
|
105
|
-
assert success.respond_to?(:xserver)
|
106
|
-
assert_equal success.xserver, @server
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_connect_should_not_retry_if_custom_auth_methods_are_given
|
110
|
-
Net::SSH.expects(:start).with(@server.host, "default-user", @options.merge(:auth_methods => %w(publickey))).raises(Net::SSH::AuthenticationFailed)
|
111
|
-
assert_raises(Net::SSH::AuthenticationFailed) { Capistrano::SSH.connect(@server, :ssh_options => { :auth_methods => %w(publickey) }) }
|
112
|
-
end
|
113
|
-
end
|
@@ -1,117 +0,0 @@
|
|
1
|
-
require "utils"
|
2
|
-
require 'capistrano/task_definition'
|
3
|
-
|
4
|
-
# Silences the wanrnings raised in the two deprecation tests
|
5
|
-
$VERBOSE = nil
|
6
|
-
|
7
|
-
class TaskDefinitionTest < Test::Unit::TestCase
|
8
|
-
def setup
|
9
|
-
@namespace = namespace
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_fqn_at_top_level_should_be_task_name
|
13
|
-
task = new_task(:testing)
|
14
|
-
assert_equal "testing", task.fully_qualified_name
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_fqn_in_namespace_should_include_namespace_fqn
|
18
|
-
ns = namespace("outer:inner")
|
19
|
-
task = new_task(:testing, ns)
|
20
|
-
assert_equal "outer:inner:testing", task.fully_qualified_name
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_fqn_at_top_level_when_default_should_be_default
|
24
|
-
task = new_task(:default)
|
25
|
-
assert_equal "default", task.fully_qualified_name
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_name_should_change_task_name
|
29
|
-
task = new_task(:foo)
|
30
|
-
task.name = :bar
|
31
|
-
|
32
|
-
assert_equal :bar, task.name
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_raise_an_exception_when_task_names_can_not_be_converted
|
36
|
-
task = new_task('valid task name')
|
37
|
-
|
38
|
-
assert_raises(ArgumentError) { task.name = ['invalid task name'] }
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_fqn_in_namespace_when_default_should_be_namespace_fqn
|
42
|
-
ns = namespace("outer:inner")
|
43
|
-
task = new_task(:default, ns)
|
44
|
-
ns.stubs(:default_task => task)
|
45
|
-
assert_equal "outer:inner", task.fully_qualified_name
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_task_should_require_block
|
49
|
-
assert_raises(ArgumentError) do
|
50
|
-
Capistrano::TaskDefinition.new(:testing, @namespace)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_description_should_return_empty_string_if_not_given
|
55
|
-
assert_equal "", new_task(:testing).description
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_description_should_return_desc_attribute
|
59
|
-
assert_equal "something", new_task(:testing, @namespace, :desc => "something").description
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_description_should_strip_leading_and_trailing_whitespace
|
63
|
-
assert_equal "something", new_task(:testing, @namespace, :desc => " something ").description
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_description_should_normalize_newlines
|
67
|
-
assert_equal "a\nb\nc", new_task(:testing, @namespace, :desc => "a\nb\r\nc").description
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_description_should_detect_and_remove_indentation
|
71
|
-
desc = <<-DESC
|
72
|
-
Here is some indented text \
|
73
|
-
and I want all of this to \
|
74
|
-
run together on a single line, \
|
75
|
-
without any extraneous spaces.
|
76
|
-
|
77
|
-
additional indentation will
|
78
|
-
be preserved.
|
79
|
-
DESC
|
80
|
-
|
81
|
-
task = new_task(:testing, @namespace, :desc => desc)
|
82
|
-
assert_equal "Here is some indented text and I want all of this to run together on a single line, without any extraneous spaces.\n\n additional indentation will\n be preserved.", task.description
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_description_munging_should_be_sensitive_to_code_blocks
|
86
|
-
desc = <<-DESC
|
87
|
-
Here is a line \
|
88
|
-
wrapped with spacing in it.
|
89
|
-
|
90
|
-
foo bar
|
91
|
-
baz bang
|
92
|
-
DESC
|
93
|
-
|
94
|
-
task = new_task(:testing, @namespace, :desc => desc)
|
95
|
-
assert_equal "Here is a line wrapped with spacing in it.\n\n foo bar\n baz bang", task.description
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_brief_description_should_return_first_sentence_in_description
|
99
|
-
desc = "This is the task. It does all kinds of things."
|
100
|
-
task = new_task(:testing, @namespace, :desc => desc)
|
101
|
-
assert_equal "This is the task.", task.brief_description
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_brief_description_should_truncate_if_length_given
|
105
|
-
desc = "This is the task that does all kinds of things. And then some."
|
106
|
-
task = new_task(:testing, @namespace, :desc => desc)
|
107
|
-
assert_equal "This is the task ...", task.brief_description(20)
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_brief_description_should_not_break_at_period_in_middle_of_sentence
|
111
|
-
task = new_task(:testing, @namespace, :desc => "Take file.txt and copy it.")
|
112
|
-
assert_equal "Take file.txt and copy it.", task.brief_description
|
113
|
-
|
114
|
-
task = new_task(:testing, @namespace, :desc => "Take file.txt and copy it. Then do something else.")
|
115
|
-
assert_equal "Take file.txt and copy it.", task.brief_description
|
116
|
-
end
|
117
|
-
end
|
data/test/transfer_test.rb
DELETED
@@ -1,168 +0,0 @@
|
|
1
|
-
require 'utils'
|
2
|
-
require 'capistrano/transfer'
|
3
|
-
|
4
|
-
class TransferTest < Test::Unit::TestCase
|
5
|
-
def test_class_process_should_delegate_to_instance_process
|
6
|
-
Capistrano::Transfer.expects(:new).with(:up, "from", "to", %w(a b c), {}).returns(mock('transfer', :process! => nil)).yields
|
7
|
-
yielded = false
|
8
|
-
Capistrano::Transfer.process(:up, "from", "to", %w(a b c), {}) { yielded = true }
|
9
|
-
assert yielded
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_default_transport_is_sftp
|
13
|
-
transfer = Capistrano::Transfer.new(:up, "from", "to", [])
|
14
|
-
assert_equal :sftp, transfer.transport
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_active_is_true_when_any_sftp_transfers_are_active
|
18
|
-
returns = [false, false, true]
|
19
|
-
sessions = [session('app1', :sftp), session('app2', :sftp), session('app3', :sftp)].each { |s| s.xsftp.expects(:upload).returns(stub('operation', :active? => returns.shift)) }
|
20
|
-
transfer = Capistrano::Transfer.new(:up, "from", "to", sessions, :via => :sftp)
|
21
|
-
assert_equal true, transfer.active?
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_active_is_false_when_all_sftp_transfers_are_not_active
|
25
|
-
sessions = [session('app1', :sftp), session('app2', :sftp)].each { |s| s.xsftp.expects(:upload).returns(stub('operation', :active? => false)) }
|
26
|
-
transfer = Capistrano::Transfer.new(:up, "from", "to", sessions, :via => :sftp)
|
27
|
-
assert_equal false, transfer.active?
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_active_is_true_when_any_scp_transfers_are_active
|
31
|
-
returns = [false, false, true]
|
32
|
-
sessions = [session('app1', :scp), session('app2', :scp), session('app3', :scp)].each do |s|
|
33
|
-
channel = stub('channel', :[]= => nil, :active? => returns.shift)
|
34
|
-
s.scp.expects(:upload).returns(channel)
|
35
|
-
end
|
36
|
-
transfer = Capistrano::Transfer.new(:up, "from", "to", sessions, :via => :scp)
|
37
|
-
assert_equal true, transfer.active?
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_active_is_false_when_all_scp_transfers_are_not_active
|
41
|
-
sessions = [session('app1', :scp), session('app2', :scp), session('app3', :scp)].each do |s|
|
42
|
-
channel = stub('channel', :[]= => nil, :active? => false)
|
43
|
-
s.scp.expects(:upload).returns(channel)
|
44
|
-
end
|
45
|
-
transfer = Capistrano::Transfer.new(:up, "from", "to", sessions, :via => :scp)
|
46
|
-
assert_equal false, transfer.active?
|
47
|
-
end
|
48
|
-
|
49
|
-
[:up, :down].each do |direction|
|
50
|
-
define_method("test_sftp_#{direction}load_from_file_to_file_should_normalize_from_and_to") do
|
51
|
-
sessions = [session('app1', :sftp), session('app2', :sftp)]
|
52
|
-
|
53
|
-
sessions.each do |session|
|
54
|
-
session.xsftp.expects("#{direction}load".to_sym).with("from-#{session.xserver.host}", "to-#{session.xserver.host}",
|
55
|
-
:properties => { :server => session.xserver, :host => session.xserver.host })
|
56
|
-
end
|
57
|
-
|
58
|
-
transfer = Capistrano::Transfer.new(direction, "from-$CAPISTRANO:HOST$", "to-$CAPISTRANO:HOST$", sessions)
|
59
|
-
end
|
60
|
-
|
61
|
-
define_method("test_scp_#{direction}load_from_file_to_file_should_normalize_from_and_to") do
|
62
|
-
sessions = [session('app1', :scp), session('app2', :scp)]
|
63
|
-
|
64
|
-
sessions.each do |session|
|
65
|
-
session.scp.expects("#{direction}load".to_sym).returns({}).with("from-#{session.xserver.host}", "to-#{session.xserver.host}", :via => :scp)
|
66
|
-
end
|
67
|
-
|
68
|
-
transfer = Capistrano::Transfer.new(direction, "from-$CAPISTRANO:HOST$", "to-$CAPISTRANO:HOST$", sessions, :via => :scp)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_sftp_upload_from_IO_to_file_should_clone_the_IO_for_each_connection
|
73
|
-
sessions = [session('app1', :sftp), session('app2', :sftp)]
|
74
|
-
io = StringIO.new("from here")
|
75
|
-
|
76
|
-
sessions.each do |session|
|
77
|
-
session.xsftp.expects(:upload).with do |from, to, opts|
|
78
|
-
from != io && from.is_a?(StringIO) && from.string == io.string &&
|
79
|
-
to == "/to/here-#{session.xserver.host}" &&
|
80
|
-
opts[:properties][:server] == session.xserver &&
|
81
|
-
opts[:properties][:host] == session.xserver.host
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
transfer = Capistrano::Transfer.new(:up, StringIO.new("from here"), "/to/here-$CAPISTRANO:HOST$", sessions)
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_scp_upload_from_IO_to_file_should_clone_the_IO_for_each_connection
|
89
|
-
sessions = [session('app1', :scp), session('app2', :scp)]
|
90
|
-
io = StringIO.new("from here")
|
91
|
-
|
92
|
-
sessions.each do |session|
|
93
|
-
channel = mock('channel')
|
94
|
-
channel.expects(:[]=).with(:server, session.xserver)
|
95
|
-
channel.expects(:[]=).with(:host, session.xserver.host)
|
96
|
-
session.scp.expects(:upload).returns(channel).with do |from, to, opts|
|
97
|
-
from != io && from.is_a?(StringIO) && from.string == io.string &&
|
98
|
-
to == "/to/here-#{session.xserver.host}"
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
transfer = Capistrano::Transfer.new(:up, StringIO.new("from here"), "/to/here-$CAPISTRANO:HOST$", sessions, :via => :scp)
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_process_should_block_until_transfer_is_no_longer_active
|
106
|
-
transfer = Capistrano::Transfer.new(:up, "from", "to", [])
|
107
|
-
transfer.expects(:process_iteration).times(4).yields.returns(true,true,true,false)
|
108
|
-
transfer.expects(:active?).times(4)
|
109
|
-
transfer.process!
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_errors_raised_for_a_sftp_session_should_abort_session_and_continue_with_remaining_sessions
|
113
|
-
s = session('app1')
|
114
|
-
error = ExceptionWithSession.new(s)
|
115
|
-
transfer = Capistrano::Transfer.new(:up, "from", "to", [])
|
116
|
-
transfer.expects(:process_iteration).raises(error).times(3).returns(true, false)
|
117
|
-
txfr = mock('transfer', :abort! => true)
|
118
|
-
txfr.expects(:[]=).with(:failed, true)
|
119
|
-
txfr.expects(:[]=).with(:error, error)
|
120
|
-
transfer.expects(:session_map).returns(s => txfr)
|
121
|
-
transfer.process!
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_errors_raised_for_a_scp_session_should_abort_session_and_continue_with_remaining_sessions
|
125
|
-
s = session('app1')
|
126
|
-
error = ExceptionWithSession.new(s)
|
127
|
-
transfer = Capistrano::Transfer.new(:up, "from", "to", [], :via => :scp)
|
128
|
-
transfer.expects(:process_iteration).raises(error).times(3).returns(true, false)
|
129
|
-
txfr = mock('channel', :close => true)
|
130
|
-
txfr.expects(:[]=).with(:failed, true)
|
131
|
-
txfr.expects(:[]=).with(:error, error)
|
132
|
-
transfer.expects(:session_map).returns(s => txfr)
|
133
|
-
transfer.process!
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_uploading_a_non_existing_file_should_raise_an_understandable_error
|
137
|
-
s = session('app1')
|
138
|
-
error = Capistrano::Processable::SessionAssociation.on(ArgumentError.new('expected a file to upload'), s)
|
139
|
-
transfer = Capistrano::Transfer.new(:up, "from", "to", [], :via => :scp)
|
140
|
-
transfer.expects(:process_iteration).raises(error)
|
141
|
-
assert_raise(ArgumentError, 'expected a file to upload') { transfer.process! }
|
142
|
-
end
|
143
|
-
|
144
|
-
private
|
145
|
-
|
146
|
-
class ExceptionWithSession < ::Exception
|
147
|
-
attr_reader :session
|
148
|
-
|
149
|
-
def initialize(session)
|
150
|
-
@session = session
|
151
|
-
super()
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def session(host, mode=nil)
|
156
|
-
session = stub('session', :xserver => stub('server', :host => host))
|
157
|
-
case mode
|
158
|
-
when :sftp
|
159
|
-
sftp = stub('sftp')
|
160
|
-
session.expects(:sftp).with(false).returns(sftp)
|
161
|
-
sftp.expects(:connect).yields(sftp).returns(sftp)
|
162
|
-
session.stubs(:xsftp).returns(sftp)
|
163
|
-
when :scp
|
164
|
-
session.stubs(:scp).returns(stub('scp'))
|
165
|
-
end
|
166
|
-
session
|
167
|
-
end
|
168
|
-
end
|
data/test/utils.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
require 'mocha'
|
6
|
-
|
7
|
-
require 'capistrano/server_definition'
|
8
|
-
require 'pry'
|
9
|
-
|
10
|
-
module TestExtensions
|
11
|
-
def server(host, options={})
|
12
|
-
Capistrano::ServerDefinition.new(host, options)
|
13
|
-
end
|
14
|
-
|
15
|
-
def namespace(fqn=nil)
|
16
|
-
space = stub(:roles => {}, :fully_qualified_name => fqn, :default_task => nil)
|
17
|
-
yield(space) if block_given?
|
18
|
-
space
|
19
|
-
end
|
20
|
-
|
21
|
-
def role(space, name, *args)
|
22
|
-
opts = args.last.is_a?(Hash) ? args.pop : {}
|
23
|
-
space.roles[name] ||= []
|
24
|
-
space.roles[name].concat(args.map { |h| Capistrano::ServerDefinition.new(h, opts) })
|
25
|
-
end
|
26
|
-
|
27
|
-
def new_task(name, namespace=@namespace, options={}, &block)
|
28
|
-
block ||= Proc.new {}
|
29
|
-
task = Capistrano::TaskDefinition.new(name, namespace, options, &block)
|
30
|
-
assert_equal block, task.body
|
31
|
-
return task
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Test::Unit::TestCase
|
36
|
-
include TestExtensions
|
37
|
-
end
|
data/test/version_test.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'capistrano/version'
|
2
|
-
|
3
|
-
class VersionTest < Test::Unit::TestCase
|
4
|
-
def test_version_constant_is_not_nil
|
5
|
-
assert_not_nil Capistrano::VERSION
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_version_constant_matches_class_method
|
9
|
-
assert_equal Capistrano::VERSION, Capistrano::Version.to_s
|
10
|
-
end
|
11
|
-
end
|