capistrano 2.1.0 → 3.0.0

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.
Files changed (166) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +7 -0
  4. data/CHANGELOG.md +89 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +674 -0
  7. data/README.md +226 -0
  8. data/Rakefile +5 -0
  9. data/bin/cap +2 -3
  10. data/bin/capify +7 -77
  11. data/capistrano-public_cert.pem +22 -0
  12. data/capistrano.gemspec +35 -0
  13. data/features/deploy.feature +52 -0
  14. data/features/installation.feature +16 -0
  15. data/features/remote_file_task.feature +14 -0
  16. data/features/step_definitions/assertions.rb +90 -0
  17. data/features/step_definitions/cap_commands.rb +8 -0
  18. data/features/step_definitions/setup.rb +25 -0
  19. data/features/support/env.rb +12 -0
  20. data/features/support/remote_command_helpers.rb +20 -0
  21. data/lib/Capfile +3 -0
  22. data/lib/capistrano/all.rb +16 -0
  23. data/lib/capistrano/application.rb +60 -0
  24. data/lib/capistrano/configuration/question.rb +42 -0
  25. data/lib/capistrano/configuration/server.rb +133 -0
  26. data/lib/capistrano/configuration/servers/role_filter.rb +86 -0
  27. data/lib/capistrano/configuration/servers.rb +53 -58
  28. data/lib/capistrano/configuration.rb +84 -30
  29. data/lib/capistrano/console.rb +1 -0
  30. data/lib/capistrano/defaults.rb +13 -0
  31. data/lib/capistrano/deploy.rb +3 -0
  32. data/lib/capistrano/dotfile.rb +3 -0
  33. data/lib/capistrano/dsl/env.rb +64 -0
  34. data/lib/capistrano/dsl/paths.rb +94 -0
  35. data/lib/capistrano/dsl/stages.rb +15 -0
  36. data/lib/capistrano/dsl/task_enhancements.rb +53 -0
  37. data/lib/capistrano/dsl.rb +48 -0
  38. data/lib/capistrano/git.rb +1 -0
  39. data/lib/capistrano/hg.rb +1 -0
  40. data/lib/capistrano/i18n.rb +34 -0
  41. data/lib/capistrano/install.rb +1 -0
  42. data/lib/capistrano/setup.rb +21 -0
  43. data/lib/capistrano/tasks/console.rake +21 -0
  44. data/lib/capistrano/tasks/deploy.rake +204 -0
  45. data/lib/capistrano/tasks/framework.rake +67 -0
  46. data/lib/capistrano/tasks/git.rake +62 -0
  47. data/lib/capistrano/tasks/hg.rake +39 -0
  48. data/lib/capistrano/tasks/install.rake +39 -0
  49. data/lib/capistrano/templates/Capfile +26 -0
  50. data/lib/capistrano/templates/deploy.rb.erb +40 -0
  51. data/lib/capistrano/templates/stage.rb.erb +42 -0
  52. data/lib/capistrano/version.rb +1 -20
  53. data/lib/capistrano/version_validator.rb +37 -0
  54. data/lib/capistrano.rb +0 -2
  55. data/spec/integration/dsl_spec.rb +344 -0
  56. data/spec/integration_spec_helper.rb +7 -0
  57. data/spec/lib/capistrano/application_spec.rb +61 -0
  58. data/spec/lib/capistrano/configuration/question_spec.rb +54 -0
  59. data/spec/lib/capistrano/configuration/server_spec.rb +249 -0
  60. data/spec/lib/capistrano/configuration/servers/role_filter_spec.rb +140 -0
  61. data/spec/lib/capistrano/configuration/servers_spec.rb +184 -0
  62. data/spec/lib/capistrano/configuration_spec.rb +101 -0
  63. data/spec/lib/capistrano/dsl/env_spec.rb +10 -0
  64. data/spec/lib/capistrano/dsl/paths_spec.rb +69 -0
  65. data/spec/lib/capistrano/dsl_spec.rb +63 -0
  66. data/spec/lib/capistrano/version_validator_spec.rb +103 -0
  67. data/spec/lib/capistrano_spec.rb +8 -0
  68. data/spec/spec_helper.rb +15 -0
  69. data/spec/support/.gitignore +1 -0
  70. data/spec/support/Vagrantfile +13 -0
  71. data/spec/support/matchers.rb +5 -0
  72. data/spec/support/tasks/database.cap +11 -0
  73. data/spec/support/test_app.rb +138 -0
  74. metadata +251 -179
  75. data/CHANGELOG +0 -512
  76. data/MIT-LICENSE +0 -20
  77. data/README +0 -43
  78. data/examples/sample.rb +0 -14
  79. data/lib/capistrano/callback.rb +0 -45
  80. data/lib/capistrano/cli/execute.rb +0 -82
  81. data/lib/capistrano/cli/help.rb +0 -102
  82. data/lib/capistrano/cli/help.txt +0 -53
  83. data/lib/capistrano/cli/options.rb +0 -183
  84. data/lib/capistrano/cli/ui.rb +0 -28
  85. data/lib/capistrano/cli.rb +0 -47
  86. data/lib/capistrano/command.rb +0 -161
  87. data/lib/capistrano/configuration/actions/file_transfer.rb +0 -35
  88. data/lib/capistrano/configuration/actions/inspect.rb +0 -46
  89. data/lib/capistrano/configuration/actions/invocation.rb +0 -134
  90. data/lib/capistrano/configuration/callbacks.rb +0 -148
  91. data/lib/capistrano/configuration/connections.rb +0 -159
  92. data/lib/capistrano/configuration/execution.rb +0 -126
  93. data/lib/capistrano/configuration/loading.rb +0 -198
  94. data/lib/capistrano/configuration/namespaces.rb +0 -196
  95. data/lib/capistrano/configuration/roles.rb +0 -51
  96. data/lib/capistrano/configuration/variables.rb +0 -127
  97. data/lib/capistrano/errors.rb +0 -15
  98. data/lib/capistrano/extensions.rb +0 -57
  99. data/lib/capistrano/gateway.rb +0 -131
  100. data/lib/capistrano/logger.rb +0 -59
  101. data/lib/capistrano/recipes/compat.rb +0 -32
  102. data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
  103. data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -46
  104. data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -96
  105. data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
  106. data/lib/capistrano/recipes/deploy/scm/base.rb +0 -192
  107. data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
  108. data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -151
  109. data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -85
  110. data/lib/capistrano/recipes/deploy/scm/git.rb +0 -191
  111. data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -129
  112. data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -126
  113. data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -114
  114. data/lib/capistrano/recipes/deploy/scm.rb +0 -19
  115. data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -64
  116. data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
  117. data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -144
  118. data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
  119. data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
  120. data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -47
  121. data/lib/capistrano/recipes/deploy/strategy.rb +0 -19
  122. data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
  123. data/lib/capistrano/recipes/deploy.rb +0 -494
  124. data/lib/capistrano/recipes/standard.rb +0 -37
  125. data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
  126. data/lib/capistrano/recipes/upgrade.rb +0 -33
  127. data/lib/capistrano/server_definition.rb +0 -51
  128. data/lib/capistrano/shell.rb +0 -256
  129. data/lib/capistrano/ssh.rb +0 -109
  130. data/lib/capistrano/task_definition.rb +0 -69
  131. data/lib/capistrano/upload.rb +0 -146
  132. data/test/cli/execute_test.rb +0 -132
  133. data/test/cli/help_test.rb +0 -139
  134. data/test/cli/options_test.rb +0 -226
  135. data/test/cli/ui_test.rb +0 -28
  136. data/test/cli_test.rb +0 -17
  137. data/test/command_test.rb +0 -309
  138. data/test/configuration/actions/file_transfer_test.rb +0 -40
  139. data/test/configuration/actions/inspect_test.rb +0 -62
  140. data/test/configuration/actions/invocation_test.rb +0 -202
  141. data/test/configuration/callbacks_test.rb +0 -206
  142. data/test/configuration/connections_test.rb +0 -288
  143. data/test/configuration/execution_test.rb +0 -159
  144. data/test/configuration/loading_test.rb +0 -127
  145. data/test/configuration/namespace_dsl_test.rb +0 -297
  146. data/test/configuration/roles_test.rb +0 -47
  147. data/test/configuration/servers_test.rb +0 -90
  148. data/test/configuration/variables_test.rb +0 -180
  149. data/test/configuration_test.rb +0 -81
  150. data/test/deploy/scm/accurev_test.rb +0 -23
  151. data/test/deploy/scm/base_test.rb +0 -55
  152. data/test/deploy/scm/git_test.rb +0 -112
  153. data/test/deploy/strategy/copy_test.rb +0 -147
  154. data/test/extensions_test.rb +0 -69
  155. data/test/fixtures/cli_integration.rb +0 -5
  156. data/test/fixtures/config.rb +0 -5
  157. data/test/fixtures/custom.rb +0 -3
  158. data/test/gateway_test.rb +0 -167
  159. data/test/logger_test.rb +0 -123
  160. data/test/server_definition_test.rb +0 -108
  161. data/test/shell_test.rb +0 -64
  162. data/test/ssh_test.rb +0 -97
  163. data/test/task_definition_test.rb +0 -101
  164. data/test/upload_test.rb +0 -131
  165. data/test/utils.rb +0 -42
  166. data/test/version_test.rb +0 -24
@@ -1,180 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../utils"
2
- require 'capistrano/configuration/variables'
3
-
4
- class ConfigurationVariablesTest < Test::Unit::TestCase
5
- class MockConfig
6
- attr_reader :original_initialize_called
7
-
8
- def initialize
9
- @original_initialize_called = true
10
- end
11
-
12
- include Capistrano::Configuration::Variables
13
- end
14
-
15
- def setup
16
- MockConfig.any_instance.stubs(:logger).returns(stub_everything)
17
- @config = MockConfig.new
18
- end
19
-
20
- def test_initialize_should_initialize_variables_hash
21
- assert @config.original_initialize_called
22
- assert_equal({:ssh_options => {}, :logger => @config.logger}, @config.variables)
23
- end
24
-
25
- def test_set_should_add_variable_to_hash
26
- @config.set :sample, :value
27
- assert_equal :value, @config.variables[:sample]
28
- end
29
-
30
- def test_set_should_convert_variable_name_to_symbol
31
- @config.set "sample", :value
32
- assert_equal :value, @config.variables[:sample]
33
- end
34
-
35
- def test_set_should_be_aliased_to_square_brackets
36
- @config[:sample] = :value
37
- assert_equal :value, @config.variables[:sample]
38
- end
39
-
40
- def test_variables_should_be_accessible_as_read_accessors
41
- @config[:sample] = :value
42
- assert_equal :value, @config.sample
43
- end
44
-
45
- def test_method_missing_should_raise_error_if_no_variable_matches
46
- assert_raises(NoMethodError) do
47
- @config.sample
48
- end
49
- end
50
-
51
- def test_respond_to_should_look_for_variables
52
- assert !@config.respond_to?(:sample)
53
- @config[:sample] = :value
54
- assert @config.respond_to?(:sample)
55
- end
56
-
57
- def test_set_should_require_value
58
- assert_raises(ArgumentError) do
59
- @config.set(:sample)
60
- end
61
- end
62
-
63
- def test_set_should_allow_value_to_be_omitted_if_block_is_given
64
- assert_nothing_raised do
65
- @config.set(:sample) { :value }
66
- end
67
- assert_instance_of Proc, @config.variables[:sample]
68
- end
69
-
70
- def test_set_should_not_allow_multiple_values
71
- assert_raises(ArgumentError) do
72
- @config.set(:sample, :value, :another)
73
- end
74
- end
75
-
76
- def test_set_should_not_allow_both_a_value_and_a_block
77
- assert_raises(ArgumentError) do
78
- @config.set(:sample, :value) { :block }
79
- end
80
- end
81
-
82
- def test_set_should_not_allow_capitalized_variables
83
- assert_raises(ArgumentError) do
84
- @config.set :Sample, :value
85
- end
86
- end
87
-
88
- def test_unset_should_remove_variable_from_hash
89
- @config.set :sample, :value
90
- assert @config.variables.key?(:sample)
91
- @config.unset :sample
92
- assert !@config.variables.key?(:sample)
93
- end
94
-
95
- def test_unset_should_clear_memory_of_original_proc
96
- @config.set(:sample) { :value }
97
- @config.fetch(:sample)
98
- @config.unset(:sample)
99
- assert_equal false, @config.reset!(:sample)
100
- end
101
-
102
- def test_exists_should_report_existance_of_variable_in_hash
103
- assert !@config.exists?(:sample)
104
- @config[:sample] = :value
105
- assert @config.exists?(:sample)
106
- end
107
-
108
- def test_reset_should_do_nothing_if_variable_does_not_exist
109
- assert_equal false, @config.reset!(:sample)
110
- assert !@config.variables.key?(:sample)
111
- end
112
-
113
- def test_reset_should_do_nothing_if_variable_is_not_a_proc
114
- @config.set(:sample, :value)
115
- assert_equal false, @config.reset!(:sample)
116
- assert_equal :value, @config.variables[:sample]
117
- end
118
-
119
- def test_reset_should_do_nothing_if_proc_variable_has_not_been_dereferenced
120
- @config.set(:sample) { :value }
121
- assert_equal false, @config.reset!(:sample)
122
- assert_instance_of Proc, @config.variables[:sample]
123
- end
124
-
125
- def test_reset_should_restore_variable_to_original_proc_value
126
- @config.set(:sample) { :value }
127
- assert_instance_of Proc, @config.variables[:sample]
128
- @config.fetch(:sample)
129
- assert_instance_of Symbol, @config.variables[:sample]
130
- assert @config.reset!(:sample)
131
- assert_instance_of Proc, @config.variables[:sample]
132
- end
133
-
134
- def test_fetch_should_return_stored_non_proc_value
135
- @config.set(:sample, :value)
136
- assert_equal :value, @config.fetch(:sample)
137
- end
138
-
139
- def test_fetch_should_raise_index_error_if_variable_does_not_exist
140
- assert_raises(IndexError) do
141
- @config.fetch(:sample)
142
- end
143
- end
144
-
145
- def test_fetch_should_return_default_if_variable_does_not_exist_and_default_is_given
146
- assert_nothing_raised do
147
- assert_equal :default_value, @config.fetch(:sample, :default_value)
148
- end
149
- end
150
-
151
- def test_fetch_should_invoke_block_if_variable_does_not_exist_and_block_is_given
152
- assert_nothing_raised do
153
- assert_equal :default_value, @config.fetch(:sample) { :default_value }
154
- end
155
- end
156
-
157
- def test_fetch_should_raise_argument_error_if_both_default_and_block_are_given
158
- assert_raises(ArgumentError) do
159
- @config.fetch(:sample, :default1) { :default2 }
160
- end
161
- end
162
-
163
- def test_fetch_should_dereference_proc_values
164
- @config.set(:sample) { :value }
165
- assert_instance_of Proc, @config.variables[:sample]
166
- assert_equal :value, @config.fetch(:sample)
167
- assert_instance_of Symbol, @config.variables[:sample]
168
- end
169
-
170
- def test_square_brackets_should_alias_fetch
171
- @config.set(:sample, :value)
172
- assert_equal :value, @config[:sample]
173
- end
174
-
175
- def test_square_brackets_should_return_nil_for_non_existant_variable
176
- assert_nothing_raised do
177
- assert_nil @config[:sample]
178
- end
179
- end
180
- end
@@ -1,81 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/utils"
2
- require 'capistrano/configuration'
3
-
4
- # These tests are only for testing the integration of the various components
5
- # of the Configuration class. To test specific features, please look at the
6
- # tests under test/configuration.
7
-
8
- class ConfigurationTest < Test::Unit::TestCase
9
- def setup
10
- @config = Capistrano::Configuration.new
11
- end
12
-
13
- def test_connections_execution_loading_namespaces_roles_and_variables_modules_should_integrate_correctly
14
- Capistrano::SSH.expects(:connect).with { |s,c| s.host == "www.capistrano.test" && c == @config }.returns(:session)
15
- Capistrano::Command.expects(:process).with("echo 'hello world'", [:session], :logger => @config.logger)
16
-
17
- @config.load do
18
- role :test, "www.capistrano.test"
19
- set :message, "hello world"
20
- namespace :testing do
21
- task :example, :roles => :test do
22
- run "echo '#{message}'"
23
- end
24
- end
25
- end
26
-
27
- @config.testing.example
28
- end
29
-
30
- def test_tasks_in_nested_namespace_should_be_able_to_call_tasks_in_same_namespace
31
- @config.namespace(:outer) do
32
- task(:first) { set :called_first, true }
33
- namespace(:inner) do
34
- task(:first) { set :called_inner_first, true }
35
- task(:second) { first }
36
- end
37
- end
38
-
39
- @config.outer.inner.second
40
- assert !@config[:called_first]
41
- assert @config[:called_inner_first]
42
- end
43
-
44
- def test_tasks_in_nested_namespace_should_be_able_to_call_tasks_in_parent_namespace
45
- @config.namespace(:outer) do
46
- task(:first) { set :called_first, true }
47
- namespace(:inner) do
48
- task(:second) { first }
49
- end
50
- end
51
-
52
- @config.outer.inner.second
53
- assert @config[:called_first]
54
- end
55
-
56
- def test_tasks_in_nested_namespace_should_be_able_to_call_shadowed_tasks_in_parent_namespace
57
- @config.namespace(:outer) do
58
- task(:first) { set :called_first, true }
59
- namespace(:inner) do
60
- task(:first) { set :called_inner_first, true }
61
- task(:second) { parent.first }
62
- end
63
- end
64
-
65
- @config.outer.inner.second
66
- assert @config[:called_first]
67
- assert !@config[:called_inner_first]
68
- end
69
-
70
- def test_hooks_for_default_task_should_be_found_if_named_after_the_namespace
71
- @config.namespace(:outer) do
72
- task(:default) { set :called_default, true }
73
- task(:before_outer) { set :called_before_outer, true }
74
- task(:after_outer) { set :called_after_outer, true }
75
- end
76
- @config.outer.default
77
- assert @config[:called_before_outer]
78
- assert @config[:called_default]
79
- assert @config[:called_after_outer]
80
- end
81
- end
@@ -1,23 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../../utils"
2
- require 'capistrano/recipes/deploy/scm/accurev'
3
-
4
- class AccurevTest < Test::Unit::TestCase
5
- include Capistrano::Deploy::SCM
6
-
7
- def test_internal_revision_to_s
8
- assert_equal 'foo/1', Accurev::InternalRevision.new('foo', 1).to_s
9
- assert_equal 'foo/highest', Accurev::InternalRevision.new('foo', 'highest').to_s
10
- end
11
-
12
- def test_internal_revision_parse
13
- revision = Accurev::InternalRevision.parse('foo')
14
- assert_equal 'foo', revision.stream
15
- assert_equal 'highest', revision.transaction_id
16
- assert_equal 'foo/highest', revision.to_s
17
-
18
- revision = Accurev::InternalRevision.parse('foo/1')
19
- assert_equal 'foo', revision.stream
20
- assert_equal '1', revision.transaction_id
21
- assert_equal 'foo/1', revision.to_s
22
- end
23
- end
@@ -1,55 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../../utils"
2
- require 'capistrano/recipes/deploy/scm/base'
3
-
4
- class DeploySCMBaseTest < Test::Unit::TestCase
5
- class TestSCM < Capistrano::Deploy::SCM::Base
6
- default_command "floopy"
7
- end
8
-
9
- def setup
10
- @config = { }
11
- def @config.exists?(name); key?(name); end
12
-
13
- @source = TestSCM.new(@config)
14
- end
15
-
16
- def test_command_should_default_to_default_command
17
- assert_equal "floopy", @source.command
18
- @source.local { assert_equal "floopy", @source.command }
19
- end
20
-
21
- def test_command_should_use_scm_command_if_available
22
- @config[:scm_command] = "/opt/local/bin/floopy"
23
- assert_equal "/opt/local/bin/floopy", @source.command
24
- end
25
-
26
- def test_command_should_use_scm_command_in_local_mode_if_local_scm_command_not_set
27
- @config[:scm_command] = "/opt/local/bin/floopy"
28
- @source.local { assert_equal "/opt/local/bin/floopy", @source.command }
29
- end
30
-
31
- def test_command_should_use_local_scm_command_in_local_mode_if_local_scm_command_is_set
32
- @config[:scm_command] = "/opt/local/bin/floopy"
33
- @config[:local_scm_command] = "/usr/local/bin/floopy"
34
- assert_equal "/opt/local/bin/floopy", @source.command
35
- @source.local { assert_equal "/usr/local/bin/floopy", @source.command }
36
- end
37
-
38
- def test_command_should_use_default_if_scm_command_is_default
39
- @config[:scm_command] = :default
40
- assert_equal "floopy", @source.command
41
- end
42
-
43
- def test_command_should_use_default_in_local_mode_if_local_scm_command_is_default
44
- @config[:scm_command] = "/foo/bar/floopy"
45
- @config[:local_scm_command] = :default
46
- @source.local { assert_equal "floopy", @source.command }
47
- end
48
-
49
- def test_local_mode_proxy_should_treat_messages_as_being_in_local_mode
50
- @config[:scm_command] = "/foo/bar/floopy"
51
- @config[:local_scm_command] = :default
52
- assert_equal "floopy", @source.local.command
53
- assert_equal "/foo/bar/floopy", @source.command
54
- end
55
- end
@@ -1,112 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../../utils"
2
- require 'capistrano/recipes/deploy/scm/git'
3
-
4
- class DeploySCMGitTest < Test::Unit::TestCase
5
- class TestSCM < Capistrano::Deploy::SCM::Git
6
- default_command "git"
7
- end
8
-
9
- def setup
10
- @config = { }
11
- def @config.exists?(name); key?(name); end
12
-
13
- @source = TestSCM.new(@config)
14
- end
15
-
16
- def test_head
17
- assert_equal "HEAD", @source.head
18
- @config[:branch] = "master"
19
- assert_equal "master", @source.head
20
- end
21
-
22
- def test_checkout
23
- @config[:repository] = "git@somehost.com:project.git"
24
- dest = "/var/www"
25
- assert_equal "git clone git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy HEAD", @source.checkout('Not used', dest)
26
-
27
- # With branch
28
- @config[:branch] = "origin/foo"
29
- assert_equal "git clone git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy origin/foo", @source.checkout('Not used', dest)
30
- end
31
-
32
- def test_diff
33
- assert_equal "git diff master", @source.diff('master')
34
- assert_equal "git diff master..branch", @source.diff('master', 'branch')
35
- end
36
-
37
- def test_log
38
- assert_equal "git log master", @source.log('master')
39
- assert_equal "git log master..branch", @source.log('master', 'branch')
40
- end
41
-
42
- def test_query_revision
43
- assert_equal "git rev-parse HEAD", @source.query_revision('HEAD') { |o| o }
44
- end
45
-
46
- def test_command_should_be_backwards_compatible
47
- # 1.x version of this module used ":git", not ":scm_command"
48
- @config[:git] = "/srv/bin/git"
49
- assert_equal "/srv/bin/git", @source.command
50
- end
51
-
52
- def test_sync
53
- dest = "/var/www"
54
- assert_equal "cd #{dest} && git fetch origin && git merge origin/HEAD", @source.sync('Not used', dest)
55
-
56
- # With branch
57
- @config[:branch] = "origin/foo"
58
- assert_equal "cd #{dest} && git fetch origin && git merge origin/foo", @source.sync('Not used', dest)
59
- end
60
-
61
- def test_shallow_clone
62
- @config[:repository] = "git@somehost.com:project.git"
63
- @config[:git_shallow_clone] = 1
64
- dest = "/var/www"
65
- assert_equal "git clone --depth 1 git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy HEAD", @source.checkout('Not used', dest)
66
-
67
- # With branch
68
- @config[:branch] = "origin/foo"
69
- assert_equal "git clone --depth 1 git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy origin/foo", @source.checkout('Not used', dest)
70
- end
71
-
72
- # Tests from base_test.rb, makin' sure we didn't break anything up there!
73
- def test_command_should_default_to_default_command
74
- assert_equal "git", @source.command
75
- @source.local { assert_equal "git", @source.command }
76
- end
77
-
78
- def test_command_should_use_scm_command_if_available
79
- @config[:scm_command] = "/opt/local/bin/git"
80
- assert_equal "/opt/local/bin/git", @source.command
81
- end
82
-
83
- def test_command_should_use_scm_command_in_local_mode_if_local_scm_command_not_set
84
- @config[:scm_command] = "/opt/local/bin/git"
85
- @source.local { assert_equal "/opt/local/bin/git", @source.command }
86
- end
87
-
88
- def test_command_should_use_local_scm_command_in_local_mode_if_local_scm_command_is_set
89
- @config[:scm_command] = "/opt/local/bin/git"
90
- @config[:local_scm_command] = "/usr/local/bin/git"
91
- assert_equal "/opt/local/bin/git", @source.command
92
- @source.local { assert_equal "/usr/local/bin/git", @source.command }
93
- end
94
-
95
- def test_command_should_use_default_if_scm_command_is_default
96
- @config[:scm_command] = :default
97
- assert_equal "git", @source.command
98
- end
99
-
100
- def test_command_should_use_default_in_local_mode_if_local_scm_command_is_default
101
- @config[:scm_command] = "/foo/bar/git"
102
- @config[:local_scm_command] = :default
103
- @source.local { assert_equal "git", @source.command }
104
- end
105
-
106
- def test_local_mode_proxy_should_treat_messages_as_being_in_local_mode
107
- @config[:scm_command] = "/foo/bar/git"
108
- @config[:local_scm_command] = :default
109
- assert_equal "git", @source.local.command
110
- assert_equal "/foo/bar/git", @source.command
111
- end
112
- end
@@ -1,147 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../../utils"
2
- require 'capistrano/logger'
3
- require 'capistrano/recipes/deploy/strategy/copy'
4
- require 'stringio'
5
-
6
- class DeployStrategyCopyTest < Test::Unit::TestCase
7
- def setup
8
- @config = { :logger => Capistrano::Logger.new(:output => StringIO.new),
9
- :releases_path => "/u/apps/test/releases",
10
- :release_path => "/u/apps/test/releases/1234567890",
11
- :real_revision => "154" }
12
- @source = mock("source")
13
- @config.stubs(:source).returns(@source)
14
- @strategy = Capistrano::Deploy::Strategy::Copy.new(@config)
15
- end
16
-
17
- def test_deploy_with_defaults_should_use_tar_gz_and_checkout
18
- Dir.expects(:tmpdir).returns("/temp/dir")
19
- Dir.expects(:chdir).with("/temp/dir").yields
20
- @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
21
-
22
- @strategy.expects(:system).with(:local_checkout)
23
- @strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
24
- @strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.tar.gz")
25
- @strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
26
-
27
- mock_file = mock("file")
28
- mock_file.expects(:puts).with("154")
29
- File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
30
- File.expects(:open).with("/temp/dir/1234567890.tar.gz", "rb").yields(StringIO.new).returns(:mock_file_contents)
31
-
32
- FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
33
- FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
34
-
35
- @strategy.deploy!
36
- end
37
-
38
- def test_deploy_with_export_should_use_tar_gz_and_export
39
- Dir.expects(:tmpdir).returns("/temp/dir")
40
- Dir.expects(:chdir).with("/temp/dir").yields
41
- @config[:copy_strategy] = :export
42
- @source.expects(:export).with("154", "/temp/dir/1234567890").returns(:local_export)
43
-
44
- @strategy.expects(:system).with(:local_export)
45
- @strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
46
- @strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.tar.gz")
47
- @strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
48
-
49
- mock_file = mock("file")
50
- mock_file.expects(:puts).with("154")
51
- File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
52
- File.expects(:open).with("/temp/dir/1234567890.tar.gz", "rb").yields(StringIO.new).returns(:mock_file_contents)
53
-
54
- FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
55
- FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
56
-
57
- @strategy.deploy!
58
- end
59
-
60
- def test_deploy_with_zip_should_use_zip_and_checkout
61
- Dir.expects(:tmpdir).returns("/temp/dir")
62
- Dir.expects(:chdir).with("/temp/dir").yields
63
- @config[:copy_compression] = :zip
64
- @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
65
-
66
- @strategy.expects(:system).with(:local_checkout)
67
- @strategy.expects(:system).with("zip -qr 1234567890.zip 1234567890")
68
- @strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.zip")
69
- @strategy.expects(:run).with("cd /u/apps/test/releases && unzip -q /tmp/1234567890.zip && rm /tmp/1234567890.zip")
70
-
71
- mock_file = mock("file")
72
- mock_file.expects(:puts).with("154")
73
- File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
74
- File.expects(:open).with("/temp/dir/1234567890.zip", "rb").yields(StringIO.new).returns(:mock_file_contents)
75
-
76
- FileUtils.expects(:rm).with("/temp/dir/1234567890.zip")
77
- FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
78
-
79
- @strategy.deploy!
80
- end
81
-
82
- def test_deploy_with_bzip2_should_use_zip_and_checkout
83
- Dir.expects(:tmpdir).returns("/temp/dir")
84
- Dir.expects(:chdir).with("/temp/dir").yields
85
- @config[:copy_compression] = :bzip2
86
- @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout)
87
-
88
- @strategy.expects(:system).with(:local_checkout)
89
- @strategy.expects(:system).with("tar cjf 1234567890.tar.bz2 1234567890")
90
- @strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.tar.bz2")
91
- @strategy.expects(:run).with("cd /u/apps/test/releases && tar xjf /tmp/1234567890.tar.bz2 && rm /tmp/1234567890.tar.bz2")
92
-
93
- mock_file = mock("file")
94
- mock_file.expects(:puts).with("154")
95
- File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
96
- File.expects(:open).with("/temp/dir/1234567890.tar.bz2", "rb").yields(StringIO.new).returns(:mock_file_contents)
97
-
98
- FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.bz2")
99
- FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
100
-
101
- @strategy.deploy!
102
- end
103
-
104
- def test_deploy_with_custom_copy_dir_should_use_that_as_tmpdir
105
- Dir.expects(:tmpdir).never
106
- Dir.expects(:chdir).with("/other/path").yields
107
- @config[:copy_dir] = "/other/path"
108
- @source.expects(:checkout).with("154", "/other/path/1234567890").returns(:local_checkout)
109
-
110
- @strategy.expects(:system).with(:local_checkout)
111
- @strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
112
- @strategy.expects(:put).with(:mock_file_contents, "/tmp/1234567890.tar.gz")
113
- @strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz")
114
-
115
- mock_file = mock("file")
116
- mock_file.expects(:puts).with("154")
117
- File.expects(:open).with("/other/path/1234567890/REVISION", "w").yields(mock_file)
118
- File.expects(:open).with("/other/path/1234567890.tar.gz", "rb").yields(StringIO.new).returns(:mock_file_contents)
119
-
120
- FileUtils.expects(:rm).with("/other/path/1234567890.tar.gz")
121
- FileUtils.expects(:rm_rf).with("/other/path/1234567890")
122
-
123
- @strategy.deploy!
124
- end
125
-
126
- def test_deploy_with_copy_remote_dir_should_copy_to_that_dir
127
- @config[:copy_remote_dir] = "/somewhere/else"
128
- Dir.expects(:tmpdir).returns("/temp/dir")
129
- Dir.expects(:chdir).yields
130
- @source.expects(:checkout).returns(:local_checkout)
131
-
132
- @strategy.expects(:system).with(:local_checkout)
133
- @strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890")
134
- @strategy.expects(:put).with(:mock_file_contents, "/somewhere/else/1234567890.tar.gz")
135
- @strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /somewhere/else/1234567890.tar.gz && rm /somewhere/else/1234567890.tar.gz")
136
-
137
- mock_file = mock("file")
138
- mock_file.expects(:puts).with("154")
139
- File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file)
140
- File.expects(:open).with("/temp/dir/1234567890.tar.gz", "rb").yields(StringIO.new).returns(:mock_file_contents)
141
-
142
- FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz")
143
- FileUtils.expects(:rm_rf).with("/temp/dir/1234567890")
144
-
145
- @strategy.deploy!
146
- end
147
- end
@@ -1,69 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/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
@@ -1,5 +0,0 @@
1
- role :test, "www.capistrano.test"
2
-
3
- task :testing, :roles => :test do
4
- set :testing_occurred, true
5
- end
@@ -1,5 +0,0 @@
1
- set :application, "foo"
2
- set :repository, "1/2/#{application}"
3
- set :gateway, "#{__FILE__}.example.com"
4
-
5
- role :web, "www.example.com", :primary => true
@@ -1,3 +0,0 @@
1
- ConfigurationLoadingTest::MockConfig.instance(:must_exist).load do
2
- ping! :custom
3
- end