capistrano 2.8.0 → 3.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. checksums.yaml +7 -0
  2. data/.docker/Dockerfile +7 -0
  3. data/.docker/ssh_key_rsa +49 -0
  4. data/.docker/ssh_key_rsa.pub +1 -0
  5. data/.docker/ubuntu_setup.sh +23 -0
  6. data/.github/issue_template.md +19 -0
  7. data/.github/pull_request_template.md +22 -0
  8. data/.github/release-drafter.yml +25 -0
  9. data/.github/workflows/ci.yml +80 -0
  10. data/.github/workflows/release-drafter.yml +18 -0
  11. data/.gitignore +23 -8
  12. data/.rubocop.yml +62 -0
  13. data/CHANGELOG.md +1 -0
  14. data/CONTRIBUTING.md +63 -0
  15. data/DEVELOPMENT.md +112 -0
  16. data/Gemfile +42 -9
  17. data/LICENSE.txt +21 -0
  18. data/README.md +221 -0
  19. data/RELEASING.md +17 -0
  20. data/Rakefile +17 -8
  21. data/UPGRADING-3.7.md +86 -0
  22. data/bin/cap +2 -3
  23. data/bin/capify +7 -89
  24. data/capistrano.gemspec +29 -43
  25. data/docker-compose.yml +8 -0
  26. data/features/configuration.feature +28 -0
  27. data/features/deploy.feature +92 -0
  28. data/features/deploy_failure.feature +17 -0
  29. data/features/doctor.feature +11 -0
  30. data/features/installation.feature +21 -0
  31. data/features/sshconnect.feature +11 -0
  32. data/features/stage_failure.feature +9 -0
  33. data/features/step_definitions/assertions.rb +162 -0
  34. data/features/step_definitions/cap_commands.rb +21 -0
  35. data/features/step_definitions/setup.rb +91 -0
  36. data/features/subdirectory.feature +9 -0
  37. data/features/support/docker_gateway.rb +53 -0
  38. data/features/support/env.rb +1 -0
  39. data/features/support/remote_command_helpers.rb +29 -0
  40. data/features/support/remote_ssh_helpers.rb +33 -0
  41. data/lib/Capfile +3 -0
  42. data/lib/capistrano/all.rb +17 -0
  43. data/lib/capistrano/application.rb +153 -0
  44. data/lib/capistrano/configuration/empty_filter.rb +9 -0
  45. data/lib/capistrano/configuration/filter.rb +26 -0
  46. data/lib/capistrano/configuration/host_filter.rb +29 -0
  47. data/lib/capistrano/configuration/null_filter.rb +9 -0
  48. data/lib/capistrano/configuration/plugin_installer.rb +51 -0
  49. data/lib/capistrano/configuration/question.rb +76 -0
  50. data/lib/capistrano/configuration/role_filter.rb +29 -0
  51. data/lib/capistrano/configuration/scm_resolver.rb +149 -0
  52. data/lib/capistrano/configuration/server.rb +137 -0
  53. data/lib/capistrano/configuration/servers.rb +56 -96
  54. data/lib/capistrano/configuration/validated_variables.rb +110 -0
  55. data/lib/capistrano/configuration/variables.rb +79 -94
  56. data/lib/capistrano/configuration.rb +178 -33
  57. data/lib/capistrano/console.rb +1 -0
  58. data/lib/capistrano/defaults.rb +36 -0
  59. data/lib/capistrano/deploy.rb +3 -0
  60. data/lib/capistrano/doctor/environment_doctor.rb +19 -0
  61. data/lib/capistrano/doctor/gems_doctor.rb +45 -0
  62. data/lib/capistrano/doctor/output_helpers.rb +79 -0
  63. data/lib/capistrano/doctor/servers_doctor.rb +105 -0
  64. data/lib/capistrano/doctor/variables_doctor.rb +74 -0
  65. data/lib/capistrano/doctor.rb +6 -0
  66. data/lib/capistrano/dotfile.rb +2 -0
  67. data/lib/capistrano/dsl/env.rb +43 -0
  68. data/lib/capistrano/dsl/paths.rb +89 -0
  69. data/lib/capistrano/dsl/stages.rb +31 -0
  70. data/lib/capistrano/dsl/task_enhancements.rb +61 -0
  71. data/lib/capistrano/dsl.rb +95 -0
  72. data/lib/capistrano/framework.rb +2 -0
  73. data/lib/capistrano/i18n.rb +46 -0
  74. data/lib/capistrano/immutable_task.rb +30 -0
  75. data/lib/capistrano/install.rb +1 -0
  76. data/lib/capistrano/plugin.rb +95 -0
  77. data/lib/capistrano/proc_helpers.rb +13 -0
  78. data/lib/capistrano/scm/git.rb +105 -0
  79. data/lib/capistrano/scm/hg.rb +55 -0
  80. data/lib/capistrano/scm/plugin.rb +13 -0
  81. data/lib/capistrano/scm/svn.rb +56 -0
  82. data/lib/capistrano/scm/tasks/git.rake +84 -0
  83. data/lib/capistrano/scm/tasks/hg.rake +53 -0
  84. data/lib/capistrano/scm/tasks/svn.rake +53 -0
  85. data/lib/capistrano/scm.rb +115 -0
  86. data/lib/capistrano/setup.rb +36 -0
  87. data/lib/capistrano/tasks/console.rake +25 -0
  88. data/lib/capistrano/tasks/deploy.rake +280 -0
  89. data/lib/capistrano/tasks/doctor.rake +24 -0
  90. data/lib/capistrano/tasks/framework.rake +67 -0
  91. data/lib/capistrano/tasks/install.rake +41 -0
  92. data/lib/capistrano/templates/Capfile +38 -0
  93. data/lib/capistrano/templates/deploy.rb.erb +39 -0
  94. data/lib/capistrano/templates/stage.rb.erb +61 -0
  95. data/lib/capistrano/upload_task.rb +9 -0
  96. data/lib/capistrano/version.rb +1 -14
  97. data/lib/capistrano/version_validator.rb +32 -0
  98. data/lib/capistrano.rb +0 -3
  99. data/spec/integration/dsl_spec.rb +632 -0
  100. data/spec/integration_spec_helper.rb +5 -0
  101. data/spec/lib/capistrano/application_spec.rb +60 -0
  102. data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
  103. data/spec/lib/capistrano/configuration/filter_spec.rb +109 -0
  104. data/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
  105. data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
  106. data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
  107. data/spec/lib/capistrano/configuration/question_spec.rb +92 -0
  108. data/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
  109. data/spec/lib/capistrano/configuration/scm_resolver_spec.rb +56 -0
  110. data/spec/lib/capistrano/configuration/server_spec.rb +309 -0
  111. data/spec/lib/capistrano/configuration/servers_spec.rb +331 -0
  112. data/spec/lib/capistrano/configuration_spec.rb +357 -0
  113. data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
  114. data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
  115. data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
  116. data/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
  117. data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
  118. data/spec/lib/capistrano/dsl/paths_spec.rb +228 -0
  119. data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +108 -0
  120. data/spec/lib/capistrano/dsl_spec.rb +125 -0
  121. data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
  122. data/spec/lib/capistrano/plugin_spec.rb +84 -0
  123. data/spec/lib/capistrano/scm/git_spec.rb +194 -0
  124. data/spec/lib/capistrano/scm/hg_spec.rb +109 -0
  125. data/spec/lib/capistrano/scm/svn_spec.rb +137 -0
  126. data/spec/lib/capistrano/scm_spec.rb +103 -0
  127. data/spec/lib/capistrano/upload_task_spec.rb +19 -0
  128. data/spec/lib/capistrano/version_validator_spec.rb +118 -0
  129. data/spec/lib/capistrano_spec.rb +7 -0
  130. data/spec/spec_helper.rb +29 -0
  131. data/spec/support/matchers.rb +5 -0
  132. data/spec/support/tasks/database.rake +11 -0
  133. data/spec/support/tasks/fail.rake +8 -0
  134. data/spec/support/tasks/failed.rake +5 -0
  135. data/spec/support/tasks/plugin.rake +6 -0
  136. data/spec/support/tasks/root.rake +11 -0
  137. data/spec/support/test_app.rb +205 -0
  138. metadata +234 -208
  139. data/.rvmrc +0 -1
  140. data/CHANGELOG +0 -954
  141. data/README.mdown +0 -76
  142. data/lib/capistrano/callback.rb +0 -45
  143. data/lib/capistrano/cli/execute.rb +0 -85
  144. data/lib/capistrano/cli/help.rb +0 -125
  145. data/lib/capistrano/cli/help.txt +0 -81
  146. data/lib/capistrano/cli/options.rb +0 -243
  147. data/lib/capistrano/cli/ui.rb +0 -40
  148. data/lib/capistrano/cli.rb +0 -47
  149. data/lib/capistrano/command.rb +0 -286
  150. data/lib/capistrano/configuration/actions/file_transfer.rb +0 -51
  151. data/lib/capistrano/configuration/actions/inspect.rb +0 -46
  152. data/lib/capistrano/configuration/actions/invocation.rb +0 -298
  153. data/lib/capistrano/configuration/callbacks.rb +0 -148
  154. data/lib/capistrano/configuration/connections.rb +0 -230
  155. data/lib/capistrano/configuration/execution.rb +0 -143
  156. data/lib/capistrano/configuration/loading.rb +0 -197
  157. data/lib/capistrano/configuration/namespaces.rb +0 -197
  158. data/lib/capistrano/configuration/roles.rb +0 -73
  159. data/lib/capistrano/errors.rb +0 -19
  160. data/lib/capistrano/ext/string.rb +0 -5
  161. data/lib/capistrano/extensions.rb +0 -57
  162. data/lib/capistrano/logger.rb +0 -59
  163. data/lib/capistrano/processable.rb +0 -53
  164. data/lib/capistrano/recipes/compat.rb +0 -32
  165. data/lib/capistrano/recipes/deploy/assets.rb +0 -57
  166. data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
  167. data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -54
  168. data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -111
  169. data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
  170. data/lib/capistrano/recipes/deploy/scm/base.rb +0 -196
  171. data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
  172. data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -153
  173. data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -96
  174. data/lib/capistrano/recipes/deploy/scm/git.rb +0 -282
  175. data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
  176. data/lib/capistrano/recipes/deploy/scm/none.rb +0 -44
  177. data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -138
  178. data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -121
  179. data/lib/capistrano/recipes/deploy/scm.rb +0 -19
  180. data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -88
  181. data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
  182. data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -224
  183. data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
  184. data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
  185. data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -57
  186. data/lib/capistrano/recipes/deploy/strategy.rb +0 -19
  187. data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
  188. data/lib/capistrano/recipes/deploy.rb +0 -568
  189. data/lib/capistrano/recipes/standard.rb +0 -37
  190. data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
  191. data/lib/capistrano/role.rb +0 -102
  192. data/lib/capistrano/server_definition.rb +0 -56
  193. data/lib/capistrano/shell.rb +0 -260
  194. data/lib/capistrano/ssh.rb +0 -101
  195. data/lib/capistrano/task_definition.rb +0 -75
  196. data/lib/capistrano/transfer.rb +0 -216
  197. data/rvmrc.sample +0 -1
  198. data/test/cli/execute_test.rb +0 -132
  199. data/test/cli/help_test.rb +0 -165
  200. data/test/cli/options_test.rb +0 -329
  201. data/test/cli/ui_test.rb +0 -28
  202. data/test/cli_test.rb +0 -17
  203. data/test/command_test.rb +0 -289
  204. data/test/configuration/actions/file_transfer_test.rb +0 -61
  205. data/test/configuration/actions/inspect_test.rb +0 -65
  206. data/test/configuration/actions/invocation_test.rb +0 -247
  207. data/test/configuration/callbacks_test.rb +0 -220
  208. data/test/configuration/connections_test.rb +0 -420
  209. data/test/configuration/execution_test.rb +0 -175
  210. data/test/configuration/loading_test.rb +0 -132
  211. data/test/configuration/namespace_dsl_test.rb +0 -311
  212. data/test/configuration/roles_test.rb +0 -144
  213. data/test/configuration/servers_test.rb +0 -183
  214. data/test/configuration/variables_test.rb +0 -190
  215. data/test/configuration_test.rb +0 -88
  216. data/test/deploy/local_dependency_test.rb +0 -76
  217. data/test/deploy/remote_dependency_test.rb +0 -135
  218. data/test/deploy/scm/accurev_test.rb +0 -23
  219. data/test/deploy/scm/base_test.rb +0 -55
  220. data/test/deploy/scm/bzr_test.rb +0 -51
  221. data/test/deploy/scm/darcs_test.rb +0 -37
  222. data/test/deploy/scm/git_test.rb +0 -184
  223. data/test/deploy/scm/mercurial_test.rb +0 -134
  224. data/test/deploy/scm/none_test.rb +0 -35
  225. data/test/deploy/scm/subversion_test.rb +0 -32
  226. data/test/deploy/strategy/copy_test.rb +0 -321
  227. data/test/extensions_test.rb +0 -69
  228. data/test/fixtures/cli_integration.rb +0 -5
  229. data/test/fixtures/config.rb +0 -5
  230. data/test/fixtures/custom.rb +0 -3
  231. data/test/logger_test.rb +0 -123
  232. data/test/recipes_test.rb +0 -25
  233. data/test/role_test.rb +0 -11
  234. data/test/server_definition_test.rb +0 -121
  235. data/test/shell_test.rb +0 -90
  236. data/test/ssh_test.rb +0 -113
  237. data/test/task_definition_test.rb +0 -116
  238. data/test/transfer_test.rb +0 -160
  239. data/test/utils.rb +0 -37
@@ -1,132 +0,0 @@
1
- require 'utils'
2
- require 'capistrano/configuration/loading'
3
-
4
- class ConfigurationLoadingTest < Test::Unit::TestCase
5
- class MockConfig
6
- attr_accessor :ping
7
- attr_reader :original_initialize_called
8
-
9
- def initialize
10
- @original_initialize_called = true
11
- end
12
-
13
- def ping!(value)
14
- @ping = value
15
- end
16
-
17
- include Capistrano::Configuration::Loading
18
- end
19
-
20
- def setup
21
- @config = MockConfig.new
22
- end
23
-
24
- def teardown
25
- MockConfig.instance = nil
26
- $LOADED_FEATURES.delete_if { |a| a =~ /fixtures\/custom\.rb$/ }
27
- end
28
-
29
- def test_initialize_should_init_collections
30
- assert @config.original_initialize_called
31
- assert @config.load_paths.include?(".")
32
- assert @config.load_paths.detect { |v| v =~ /capistrano\/recipes$/ }
33
- end
34
-
35
- def test_load_with_options_and_block_should_raise_argument_error
36
- assert_raises(ArgumentError) do
37
- @config.load(:string => "foo") { something }
38
- end
39
- end
40
-
41
- def test_load_with_arguments_and_block_should_raise_argument_error
42
- assert_raises(ArgumentError) do
43
- @config.load("foo") { something }
44
- end
45
- end
46
-
47
- def test_load_from_string_should_eval_in_config_scope
48
- @config.load :string => "ping! :here"
49
- assert_equal :here, @config.ping
50
- end
51
-
52
- def test_load_from_file_shoudld_respect_load_path
53
- File.stubs(:file?).returns(false)
54
- File.stubs(:file?).with("custom/path/for/file.rb").returns(true)
55
- File.stubs(:read).with("custom/path/for/file.rb").returns("ping! :here")
56
-
57
- @config.load_paths << "custom/path/for"
58
- @config.load :file => "file.rb"
59
-
60
- assert_equal :here, @config.ping
61
- end
62
-
63
- def test_load_from_file_should_respect_load_path_and_appends_rb
64
- File.stubs(:file?).returns(false)
65
- File.stubs(:file?).with("custom/path/for/file.rb").returns(true)
66
- File.stubs(:read).with("custom/path/for/file.rb").returns("ping! :here")
67
-
68
- @config.load_paths << "custom/path/for"
69
- @config.load :file => "file"
70
-
71
- assert_equal :here, @config.ping
72
- end
73
-
74
- def test_load_from_file_should_raise_load_error_if_file_cannot_be_found
75
- File.stubs(:file?).returns(false)
76
- assert_raises(LoadError) do
77
- @config.load :file => "file"
78
- end
79
- end
80
-
81
- def test_load_from_proc_should_eval_proc_in_config_scope
82
- @config.load :proc => Proc.new { ping! :here }
83
- assert_equal :here, @config.ping
84
- end
85
-
86
- def test_load_with_block_should_treat_block_as_proc_parameter
87
- @config.load { ping! :here }
88
- assert_equal :here, @config.ping
89
- end
90
-
91
- def test_load_with_unrecognized_option_should_raise_argument_error
92
- assert_raises(ArgumentError) do
93
- @config.load :url => "http://www.load-this.test"
94
- end
95
- end
96
-
97
- def test_load_with_arguments_should_treat_arguments_as_files
98
- File.stubs(:file?).returns(false)
99
- File.stubs(:file?).with("./first.rb").returns(true)
100
- File.stubs(:file?).with("./second.rb").returns(true)
101
- File.stubs(:read).with("./first.rb").returns("ping! 'this'")
102
- File.stubs(:read).with("./second.rb").returns("ping << 'that'")
103
- assert_nothing_raised { @config.load "first", "second" }
104
- assert_equal "thisthat", @config.ping
105
- end
106
-
107
- def test_require_from_config_should_load_file_in_config_scope
108
- assert_nothing_raised do
109
- @config.require "#{File.expand_path(File.dirname(__FILE__))}/../fixtures/custom"
110
- end
111
- assert_equal :custom, @config.ping
112
- end
113
-
114
- def test_require_without_config_should_raise_load_error
115
- assert_raises(LoadError) do
116
- require "#{File.dirname(__FILE__)}/../fixtures/custom"
117
- end
118
- end
119
-
120
- def test_require_from_config_should_return_false_when_called_a_second_time_with_same_args
121
- assert @config.require("#{File.expand_path(File.dirname(__FILE__))}/../fixtures/custom")
122
- assert_equal false, @config.require("#{File.expand_path(File.dirname(__FILE__))}/../fixtures/custom")
123
- end
124
-
125
- def test_require_in_multiple_instances_should_load_recipes_in_each_instance
126
- config2 = MockConfig.new
127
- @config.require "#{File.expand_path(File.dirname(__FILE__))}/../fixtures/custom"
128
- config2.require "#{File.expand_path(File.dirname(__FILE__))}/../fixtures/custom"
129
- assert_equal :custom, @config.ping
130
- assert_equal :custom, config2.ping
131
- end
132
- end
@@ -1,311 +0,0 @@
1
- require "utils"
2
- require 'capistrano/configuration/namespaces'
3
-
4
- class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
5
- class MockConfig
6
- attr_reader :original_initialize_called, :options
7
-
8
- def initialize
9
- @original_initialize_called = true
10
- @options = {}
11
- end
12
-
13
- include Capistrano::Configuration::Namespaces
14
- end
15
-
16
- def setup
17
- @config = MockConfig.new
18
- end
19
-
20
- def test_initialize_should_initialize_collections
21
- assert @config.original_initialize_called
22
- assert @config.tasks.empty?
23
- assert @config.namespaces.empty?
24
- end
25
-
26
- def test_unqualified_task_should_define_task_at_top_namespace
27
- assert !@config.tasks.key?(:testing)
28
- @config.task(:testing) { puts "something" }
29
- assert @config.tasks.key?(:testing)
30
- end
31
-
32
- def test_qualification_should_define_task_within_namespace
33
- @config.namespace(:testing) do
34
- task(:nested) { puts "nested" }
35
- end
36
-
37
- assert !@config.tasks.key?(:nested)
38
- assert @config.namespaces.key?(:testing)
39
- assert @config.namespaces[:testing].tasks.key?(:nested)
40
- end
41
-
42
- def test_namespace_within_namespace_should_define_task_within_nested_namespace
43
- @config.namespace :outer do
44
- namespace :inner do
45
- task :nested do
46
- puts "nested"
47
- end
48
- end
49
- end
50
-
51
- assert !@config.tasks.key?(:nested)
52
- assert @config.namespaces.key?(:outer)
53
- assert @config.namespaces[:outer].namespaces.key?(:inner)
54
- assert @config.namespaces[:outer].namespaces[:inner].tasks.key?(:nested)
55
- end
56
-
57
- def test_pending_desc_should_apply_only_to_immediately_subsequent_task
58
- @config.desc "A description"
59
- @config.task(:testing) { puts "foo" }
60
- @config.task(:another) { puts "bar" }
61
- assert_equal "A description", @config.tasks[:testing].desc
62
- assert_nil @config.tasks[:another].desc
63
- end
64
-
65
- def test_pending_desc_should_apply_only_to_next_task_in_any_namespace
66
- @config.desc "A description"
67
- @config.namespace(:outer) { task(:testing) { puts "foo" } }
68
- assert_equal "A description", @config.namespaces[:outer].tasks[:testing].desc
69
- end
70
-
71
- def test_defining_task_without_block_should_raise_error
72
- assert_raises(ArgumentError) do
73
- @config.task(:testing)
74
- end
75
- end
76
-
77
- def test_defining_task_that_shadows_existing_method_should_raise_error
78
- assert_raises(ArgumentError) do
79
- @config.task(:sprintf) { puts "foo" }
80
- end
81
- end
82
-
83
- def test_defining_task_that_shadows_existing_namespace_should_raise_error
84
- @config.namespace(:outer) {}
85
- assert_raises(ArgumentError) do
86
- @config.task(:outer) { puts "foo" }
87
- end
88
- end
89
-
90
- def test_defining_namespace_that_shadows_existing_method_should_raise_error
91
- assert_raises(ArgumentError) do
92
- @config.namespace(:sprintf) {}
93
- end
94
- end
95
-
96
- def test_defining_namespace_that_shadows_existing_task_should_raise_error
97
- @config.task(:testing) { puts "foo" }
98
- assert_raises(ArgumentError) do
99
- @config.namespace(:testing) {}
100
- end
101
- end
102
-
103
- def test_defining_task_that_shadows_existing_task_should_not_raise_error
104
- @config.task(:original) { puts "foo" }
105
- assert_nothing_raised do
106
- @config.task(:original) { puts "bar" }
107
- end
108
- end
109
-
110
- def test_defining_ask_should_add_task_as_method
111
- assert !@config.methods.any? { |m| m.to_sym == :original }
112
- @config.task(:original) { puts "foo" }
113
- assert @config.methods.any? { |m| m.to_sym == :original }
114
- end
115
-
116
- def test_calling_defined_task_should_delegate_to_execute_task
117
- @config.task(:original) { puts "foo" }
118
- @config.expects(:execute_task).with(@config.tasks[:original])
119
- @config.original
120
- end
121
-
122
- def test_role_inside_namespace_should_raise_error
123
- assert_raises(NotImplementedError) do
124
- @config.namespace(:outer) do
125
- role :app, "hello"
126
- end
127
- end
128
- end
129
-
130
- def test_name_for_top_level_should_be_nil
131
- assert_nil @config.name
132
- end
133
-
134
- def test_parent_for_top_level_should_be_nil
135
- assert_nil @config.parent
136
- end
137
-
138
- def test_fqn_for_top_level_should_be_nil
139
- assert_nil @config.fully_qualified_name
140
- end
141
-
142
- def test_fqn_for_namespace_should_be_the_name_of_the_namespace
143
- @config.namespace(:outer) {}
144
- assert_equal "outer", @config.namespaces[:outer].fully_qualified_name
145
- end
146
-
147
- def test_parent_for_namespace_should_be_the_top_level
148
- @config.namespace(:outer) {}
149
- assert_equal @config, @config.namespaces[:outer].parent
150
- end
151
-
152
- def test_fqn_for_nested_namespace_should_be_color_delimited
153
- @config.namespace(:outer) { namespace(:inner) {} }
154
- assert_equal "outer:inner", @config.namespaces[:outer].namespaces[:inner].fully_qualified_name
155
- end
156
-
157
- def test_parent_for_nested_namespace_should_be_the_nesting_namespace
158
- @config.namespace(:outer) { namespace(:inner) {} }
159
- assert_equal @config.namespaces[:outer], @config.namespaces[:outer].namespaces[:inner].parent
160
- end
161
-
162
- def test_find_task_should_dereference_nested_tasks
163
- @config.namespace(:outer) do
164
- namespace(:inner) { task(:nested) { puts "nested" } }
165
- end
166
-
167
- task = @config.find_task("outer:inner:nested")
168
- assert_not_nil task
169
- assert_equal "outer:inner:nested", task.fully_qualified_name
170
- end
171
-
172
- def test_find_task_should_return_nil_if_no_task_matches
173
- assert_nil @config.find_task("outer:inner:nested")
174
- end
175
-
176
- def test_find_task_should_return_default_if_deferences_to_namespace_and_namespace_has_default
177
- @config.namespace(:outer) do
178
- namespace(:inner) { task(:default) { puts "nested" } }
179
- end
180
-
181
- task = @config.find_task("outer:inner")
182
- assert_not_nil task
183
- assert_equal :default, task.name
184
- assert_equal "outer:inner", task.namespace.fully_qualified_name
185
- end
186
-
187
- def test_find_task_should_return_nil_if_deferences_to_namespace_and_namespace_has_no_default
188
- @config.namespace(:outer) do
189
- namespace(:inner) { task(:nested) { puts "nested" } }
190
- end
191
-
192
- assert_nil @config.find_task("outer:inner")
193
- end
194
-
195
- def test_default_task_should_return_nil_for_top_level
196
- @config.task(:default) {}
197
- assert_nil @config.default_task
198
- end
199
-
200
- def test_default_task_should_return_nil_for_namespace_without_default
201
- @config.namespace(:outer) { task(:nested) { puts "nested" } }
202
- assert_nil @config.namespaces[:outer].default_task
203
- end
204
-
205
- def test_default_task_should_return_task_for_namespace_with_default
206
- @config.namespace(:outer) { task(:default) { puts "nested" } }
207
- task = @config.namespaces[:outer].default_task
208
- assert_not_nil task
209
- assert_equal :default, task.name
210
- end
211
-
212
- def test_task_list_should_return_only_tasks_immediately_within_namespace
213
- @config.task(:first) { puts "here" }
214
- @config.namespace(:outer) do
215
- task(:second) { puts "here" }
216
- namespace(:inner) do
217
- task(:third) { puts "here" }
218
- end
219
- end
220
-
221
- assert_equal %w(first), @config.task_list.map { |t| t.fully_qualified_name }
222
- end
223
-
224
- def test_task_list_with_all_should_return_all_tasks_under_this_namespace_recursively
225
- @config.task(:first) { puts "here" }
226
- @config.namespace(:outer) do
227
- task(:second) { puts "here" }
228
- namespace(:inner) do
229
- task(:third) { puts "here" }
230
- end
231
- end
232
-
233
- assert_equal %w(first outer:inner:third outer:second), @config.task_list(:all).map { |t| t.fully_qualified_name }.sort
234
- end
235
-
236
- def test_namespace_should_respond_to_its_parents_methods
237
- @config.namespace(:outer) {}
238
- ns = @config.namespaces[:outer]
239
- assert ns.respond_to?(:original_initialize_called)
240
- end
241
-
242
- def test_namespace_should_accept_respond_to_with_include_priv_parameter
243
- @config.namespace(:outer) {}
244
- ns = @config.namespaces[:outer]
245
- assert ns.respond_to?(:original_initialize_called, true)
246
- end
247
-
248
- def test_namespace_should_delegate_unknown_messages_to_its_parent
249
- @config.namespace(:outer) {}
250
- ns = @config.namespaces[:outer]
251
- assert ns.original_initialize_called
252
- end
253
-
254
- def test_namespace_should_not_understand_messages_that_neither_it_nor_its_parent_understands
255
- @config.namespace(:outer) {}
256
- ns = @config.namespaces[:outer]
257
- assert_raises(NoMethodError) { ns.alskdfjlsf }
258
- end
259
-
260
- def test_search_task_should_find_tasks_in_current_namespace
261
- @config.namespace(:outer) do
262
- namespace(:inner) do
263
- task(:third) { puts "here" }
264
- end
265
- end
266
-
267
- inner = @config.namespaces[:outer].namespaces[:inner]
268
- assert_equal inner.tasks[:third], inner.search_task(:third)
269
- end
270
-
271
- def test_search_task_should_find_tasks_in_parent_namespace
272
- @config.task(:first) { puts "here" }
273
- @config.namespace(:outer) do
274
- task(:second) { puts "here" }
275
- namespace(:inner) do
276
- task(:third) { puts "here" }
277
- end
278
- end
279
-
280
- inner = @config.namespaces[:outer].namespaces[:inner]
281
- assert_equal @config.tasks[:first], inner.search_task(:first)
282
- end
283
-
284
- def test_search_task_should_return_nil_if_no_tasks_are_found
285
- @config.namespace(:outer) { namespace(:inner) {} }
286
- inner = @config.namespaces[:outer].namespaces[:inner]
287
- assert_nil inner.search_task(:first)
288
- end
289
-
290
- def test_top_should_return_self_if_self_is_top
291
- assert_equal @config, @config.top
292
- end
293
-
294
- def test_top_should_return_parent_if_parent_is_top
295
- @config.namespace(:outer) {}
296
- assert_equal @config, @config.namespaces[:outer].top
297
- end
298
-
299
- def test_top_should_return_topmost_parent_if_self_is_deeply_nested
300
- @config.namespace(:outer) { namespace(:middle) { namespace(:inner) {} } }
301
- assert_equal @config, @config.namespaces[:outer].namespaces[:middle].namespaces[:inner].top
302
- end
303
-
304
- def test_find_task_should_return_nil_when_empty_inner_task
305
- @config.namespace :outer do
306
- namespace :inner do
307
- end
308
- end
309
- assert_nil @config.find_task("outer::inner")
310
- end
311
- end
@@ -1,144 +0,0 @@
1
- require "utils"
2
- require 'capistrano/configuration/roles'
3
- require 'capistrano/server_definition'
4
-
5
- class ConfigurationRolesTest < Test::Unit::TestCase
6
- class MockConfig
7
- attr_reader :original_initialize_called
8
-
9
- def initialize
10
- @original_initialize_called = true
11
- end
12
-
13
- include Capistrano::Configuration::Roles
14
- end
15
-
16
- def setup
17
- @config = MockConfig.new
18
- end
19
-
20
- def test_initialize_should_initialize_roles_collection
21
- assert @config.original_initialize_called
22
- assert @config.roles.empty?
23
- end
24
-
25
- def test_role_should_allow_empty_list
26
- @config.role :app
27
- assert @config.roles.keys.include?(:app)
28
- assert @config.roles[:app].empty?
29
- end
30
-
31
- def test_role_with_one_argument_should_add_to_roles_collection
32
- @config.role :app, "app1.capistrano.test"
33
- assert_equal [:app], @config.roles.keys
34
- assert_role_equals %w(app1.capistrano.test)
35
- end
36
-
37
- def test_role_block_returning_single_string_is_added_to_roles_collection
38
- @config.role :app do
39
- 'app1.capistrano.test'
40
- end
41
- assert_role_equals %w(app1.capistrano.test)
42
- end
43
-
44
- def test_role_with_multiple_arguments_should_add_each_to_roles_collection
45
- @config.role :app, "app1.capistrano.test", "app2.capistrano.test"
46
- assert_equal [:app], @config.roles.keys
47
- assert_role_equals %w(app1.capistrano.test app2.capistrano.test)
48
- end
49
-
50
- def test_role_with_block_and_strings_should_add_both_to_roles_collection
51
- @config.role :app, 'app1.capistrano.test' do
52
- 'app2.capistrano.test'
53
- end
54
- assert_role_equals %w(app1.capistrano.test app2.capistrano.test)
55
- end
56
-
57
- def test_role_block_returning_array_should_add_each_to_roles_collection
58
- @config.role :app do
59
- ['app1.capistrano.test', 'app2.capistrano.test']
60
- end
61
- assert_role_equals %w(app1.capistrano.test app2.capistrano.test)
62
- end
63
-
64
- def test_role_with_options_should_apply_options_to_each_argument
65
- @config.role :app, "app1.capistrano.test", "app2.capistrano.test", :extra => :value
66
- @config.roles[:app].each do |server|
67
- assert_equal({:extra => :value}, server.options)
68
- end
69
- end
70
-
71
- def test_role_with_options_should_apply_options_to_block_results
72
- @config.role :app, :extra => :value do
73
- ['app1.capistrano.test', 'app2.capistrano.test']
74
- end
75
- @config.roles[:app].each do |server|
76
- assert_equal({:extra => :value}, server.options)
77
- end
78
- end
79
-
80
- def test_options_should_apply_only_to_this_argument_set
81
- @config.role :app, 'app1.capistrano.test', 'app2.capistrano.test' do
82
- ['app3.capistrano.test', 'app4.capistrano.test']
83
- end
84
- @config.role :app, 'app5.capistrano.test', 'app6.capistrano.test', :extra => :value do
85
- ['app7.capistrano.test', 'app8.capistrano.test']
86
- end
87
- @config.role :app, 'app9.capistrano.test'
88
-
89
- option_hosts = ['app5.capistrano.test', 'app6.capistrano.test', 'app7.capistrano.test', 'app8.capistrano.test']
90
- @config.roles[:app].each do |server|
91
- if (option_hosts.include? server.host)
92
- assert_equal({:extra => :value}, server.options)
93
- else
94
- assert_not_equal({:extra => :value}, server.options)
95
- end
96
- end
97
- end
98
-
99
- # Here, the source should be more readable than the method name
100
- def test_role_block_returns_options_hash_is_merged_with_role_options_argument
101
- @config.role :app, :first => :one, :second => :two do
102
- ['app1.capistrano.test', 'app2.capistrano.test', {:second => :please, :third => :three}]
103
- end
104
- @config.roles[:app].each do |server|
105
- assert_equal({:first => :one, :second => :please, :third => :three}, server.options)
106
- end
107
- end
108
-
109
- def test_role_block_can_override_role_options_argument
110
- @config.role :app, :value => :wrong do
111
- Capistrano::ServerDefinition.new('app.capistrano.test')
112
- end
113
- @config.roles[:app].servers
114
- @config.roles[:app].servers.each do |server|
115
- assert_not_equal({:value => :wrong}, server.options)
116
- end
117
- end
118
-
119
- def test_role_block_can_return_nil
120
- @config.role :app do
121
- nil
122
- end
123
- assert_role_equals ([])
124
- end
125
-
126
- def test_role_block_can_return_empty_array
127
- @config.role :app do
128
- []
129
- end
130
- assert_role_equals ([])
131
- end
132
-
133
- def test_role_definitions_via_server_should_associate_server_with_roles
134
- @config.server "www.capistrano.test", :web, :app
135
- assert_equal %w(www.capistrano.test), @config.roles[:app].map { |s| s.host }
136
- assert_equal %w(www.capistrano.test), @config.roles[:web].map { |s| s.host }
137
- end
138
-
139
- private
140
-
141
- def assert_role_equals(list)
142
- assert_equal list, @config.roles[:app].map { |s| s.host }
143
- end
144
- end