capistrano 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,127 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../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
- $".delete "#{File.dirname(__FILE__)}/../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.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_in_multiple_instances_should_load_recipes_in_each_instance
121
- config2 = MockConfig.new
122
- @config.require "#{File.dirname(__FILE__)}/../fixtures/custom"
123
- config2.require "#{File.dirname(__FILE__)}/../fixtures/custom"
124
- assert_equal :custom, @config.ping
125
- assert_equal :custom, config2.ping
126
- end
127
- end
@@ -1,297 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../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.include?("original")
112
- @config.task(:original) { puts "foo" }
113
- assert @config.methods.include?("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_delegate_unknown_messages_to_its_parent
243
- @config.namespace(:outer) {}
244
- ns = @config.namespaces[:outer]
245
- assert ns.original_initialize_called
246
- end
247
-
248
- def test_namespace_should_not_understand_messages_that_neither_it_nor_its_parent_understands
249
- @config.namespace(:outer) {}
250
- ns = @config.namespaces[:outer]
251
- assert_raises(NoMethodError) { ns.alskdfjlsf }
252
- end
253
-
254
- def test_search_task_should_find_tasks_in_current_namespace
255
- @config.namespace(:outer) do
256
- namespace(:inner) do
257
- task(:third) { puts "here" }
258
- end
259
- end
260
-
261
- inner = @config.namespaces[:outer].namespaces[:inner]
262
- assert_equal inner.tasks[:third], inner.search_task(:third)
263
- end
264
-
265
- def test_search_task_should_find_tasks_in_parent_namespace
266
- @config.task(:first) { puts "here" }
267
- @config.namespace(:outer) do
268
- task(:second) { puts "here" }
269
- namespace(:inner) do
270
- task(:third) { puts "here" }
271
- end
272
- end
273
-
274
- inner = @config.namespaces[:outer].namespaces[:inner]
275
- assert_equal @config.tasks[:first], inner.search_task(:first)
276
- end
277
-
278
- def test_search_task_should_return_nil_if_no_tasks_are_found
279
- @config.namespace(:outer) { namespace(:inner) {} }
280
- inner = @config.namespaces[:outer].namespaces[:inner]
281
- assert_nil inner.search_task(:first)
282
- end
283
-
284
- def test_top_should_return_self_if_self_is_top
285
- assert_equal @config, @config.top
286
- end
287
-
288
- def test_top_should_return_parent_if_parent_is_top
289
- @config.namespace(:outer) {}
290
- assert_equal @config, @config.namespaces[:outer].top
291
- end
292
-
293
- def test_top_should_return_topmost_parent_if_self_is_deeply_nested
294
- @config.namespace(:outer) { namespace(:middle) { namespace(:inner) {} } }
295
- assert_equal @config, @config.namespaces[:outer].namespaces[:middle].namespaces[:inner].top
296
- end
297
- end
@@ -1,47 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../utils"
2
- require 'capistrano/configuration/roles'
3
-
4
- class ConfigurationRolesTest < 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::Roles
13
- end
14
-
15
- def setup
16
- @config = MockConfig.new
17
- end
18
-
19
- def test_initialize_should_initialize_roles_collection
20
- assert @config.original_initialize_called
21
- assert @config.roles.empty?
22
- end
23
-
24
- def test_role_should_allow_empty_list
25
- @config.role :app
26
- assert @config.roles[:app].empty?
27
- end
28
-
29
- def test_role_with_one_argument_should_add_to_roles_collection
30
- @config.role :app, "app1.capistrano.test"
31
- assert_equal [:app], @config.roles.keys
32
- assert_equal %w(app1.capistrano.test), @config.roles[:app].map { |s| s.host }
33
- end
34
-
35
- def test_role_with_multiple_arguments_should_add_each_to_roles_collection
36
- @config.role :app, "app1.capistrano.test", "app2.capistrano.test"
37
- assert_equal [:app], @config.roles.keys
38
- assert_equal %w(app1.capistrano.test app2.capistrano.test), @config.roles[:app].map { |s| s.host }
39
- end
40
-
41
- def test_role_with_options_should_apply_options_to_each_argument
42
- @config.role :app, "app1.capistrano.test", "app2.capistrano.test", :extra => :value
43
- @config.roles[:app].each do |server|
44
- assert_equal({:extra => :value}, server.options)
45
- end
46
- end
47
- end
@@ -1,90 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../utils"
2
- require 'capistrano/task_definition'
3
- require 'capistrano/configuration/servers'
4
-
5
- class ConfigurationServersTest < Test::Unit::TestCase
6
- class MockConfig
7
- attr_reader :roles
8
-
9
- def initialize
10
- @roles = {}
11
- end
12
-
13
- include Capistrano::Configuration::Servers
14
- end
15
-
16
- def setup
17
- @config = MockConfig.new
18
- role(@config, :app, "app1", :primary => true)
19
- role(@config, :app, "app2", "app3")
20
- role(@config, :web, "web1", "web2")
21
- role(@config, :report, "app2", :no_deploy => true)
22
- role(@config, :file, "file", :no_deploy => true)
23
- end
24
-
25
- def test_task_without_roles_should_apply_to_all_defined_hosts
26
- task = new_task(:testing)
27
- assert_equal %w(app1 app2 app3 web1 web2 file).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
28
- end
29
-
30
- def test_task_with_explicit_role_list_should_apply_only_to_those_roles
31
- task = new_task(:testing, @config, :roles => %w(app web))
32
- assert_equal %w(app1 app2 app3 web1 web2).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
33
- end
34
-
35
- def test_task_with_single_role_should_apply_only_to_that_role
36
- task = new_task(:testing, @config, :roles => :web)
37
- assert_equal %w(web1 web2).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
38
- end
39
-
40
- def test_task_with_hosts_option_should_apply_only_to_those_hosts
41
- task = new_task(:testing, @config, :hosts => %w(foo bar))
42
- assert_equal %w(foo bar).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
43
- end
44
-
45
- def test_task_with_single_hosts_option_should_apply_only_to_that_host
46
- task = new_task(:testing, @config, :hosts => "foo")
47
- assert_equal %w(foo).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
48
- end
49
-
50
- def test_task_with_roles_as_environment_variable_should_apply_only_to_that_role
51
- ENV['ROLES'] = "app,file"
52
- task = new_task(:testing)
53
- assert_equal %w(app1 app2 app3 file).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
54
- ensure
55
- ENV['ROLES'] = nil
56
- end
57
-
58
- def test_task_with_hosts_as_environment_variable_should_apply_only_to_those_hosts
59
- ENV['HOSTS'] = "foo,bar"
60
- task = new_task(:testing)
61
- assert_equal %w(foo bar).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
62
- ensure
63
- ENV['HOSTS'] = nil
64
- end
65
-
66
- def test_task_with_only_should_apply_only_to_matching_tasks
67
- task = new_task(:testing, @config, :roles => :app, :only => { :primary => true })
68
- assert_equal %w(app1), @config.find_servers_for_task(task).map { |s| s.host }
69
- end
70
-
71
- def test_task_with_except_should_apply_only_to_matching_tasks
72
- task = new_task(:testing, @config, :except => { :no_deploy => true })
73
- assert_equal %w(app1 app2 app3 web1 web2).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
74
- end
75
-
76
- def test_options_to_find_servers_for_task_should_override_options_in_task
77
- task = new_task(:testing, @config, :roles => :web)
78
- assert_equal %w(app1 app2 app3).sort, @config.find_servers_for_task(task, :roles => :app).map { |s| s.host }.sort
79
- end
80
-
81
- def test_find_servers_with_lambda_for_hosts_should_be_evaluated
82
- assert_equal %w(foo), @config.find_servers(:hosts => lambda { "foo" }).map { |s| s.host }.sort
83
- assert_equal %w(bar foo), @config.find_servers(:hosts => lambda { %w(foo bar) }).map { |s| s.host }.sort
84
- end
85
-
86
- def test_find_servers_with_lambda_for_roles_should_be_evaluated
87
- assert_equal %w(app1 app2 app3), @config.find_servers(:roles => lambda { :app }).map { |s| s.host }.sort
88
- assert_equal %w(app2 file), @config.find_servers(:roles => lambda { [:report, :file] }).map { |s| s.host }.sort
89
- end
90
- end