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,132 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../utils"
2
- require 'capistrano/cli/execute'
3
-
4
- class CLIExecuteTest < Test::Unit::TestCase
5
- class MockCLI
6
- attr_reader :options
7
-
8
- def initialize
9
- @options = {}
10
- end
11
-
12
- include Capistrano::CLI::Execute
13
- end
14
-
15
- def setup
16
- @cli = MockCLI.new
17
- @logger = stub_everything
18
- @config = stub(:logger => @logger)
19
- @config.stubs(:set)
20
- @config.stubs(:load)
21
- @config.stubs(:trigger)
22
- @cli.stubs(:instantiate_configuration).returns(@config)
23
- end
24
-
25
- def test_execute_should_set_logger_verbosity
26
- @cli.options[:verbose] = 7
27
- @logger.expects(:level=).with(7)
28
- @cli.execute!
29
- end
30
-
31
- def test_execute_should_set_password
32
- @cli.options[:password] = "nosoup4u"
33
- @config.expects(:set).with(:password, "nosoup4u")
34
- @cli.execute!
35
- end
36
-
37
- def test_execute_should_set_prevars_before_loading
38
- @config.expects(:load).never
39
- @config.expects(:set).with(:stage, "foobar")
40
- @config.expects(:load).with("standard")
41
- @cli.options[:pre_vars] = { :stage => "foobar" }
42
- @cli.execute!
43
- end
44
-
45
- def test_execute_should_load_sysconf_if_sysconf_set_and_exists
46
- @cli.options[:sysconf] = "/etc/capistrano.conf"
47
- @config.expects(:load).with("/etc/capistrano.conf")
48
- File.expects(:file?).with("/etc/capistrano.conf").returns(true)
49
- @cli.execute!
50
- end
51
-
52
- def test_execute_should_not_load_sysconf_when_sysconf_set_and_not_exists
53
- @cli.options[:sysconf] = "/etc/capistrano.conf"
54
- File.expects(:file?).with("/etc/capistrano.conf").returns(false)
55
- @cli.execute!
56
- end
57
-
58
- def test_execute_should_load_dotfile_if_dotfile_set_and_exists
59
- @cli.options[:dotfile] = "/home/jamis/.caprc"
60
- @config.expects(:load).with("/home/jamis/.caprc")
61
- File.expects(:file?).with("/home/jamis/.caprc").returns(true)
62
- @cli.execute!
63
- end
64
-
65
- def test_execute_should_not_load_dotfile_when_dotfile_set_and_not_exists
66
- @cli.options[:dotfile] = "/home/jamis/.caprc"
67
- File.expects(:file?).with("/home/jamis/.caprc").returns(false)
68
- @cli.execute!
69
- end
70
-
71
- def test_execute_should_load_recipes_when_recipes_are_given
72
- @cli.options[:recipes] = %w(config/deploy path/to/extra)
73
- @config.expects(:load).with("config/deploy")
74
- @config.expects(:load).with("path/to/extra")
75
- @cli.execute!
76
- end
77
-
78
- def test_execute_should_set_vars_and_execute_tasks
79
- @cli.options[:vars] = { :foo => "bar", :baz => "bang" }
80
- @cli.options[:actions] = %w(first second)
81
- @config.expects(:set).with(:foo, "bar")
82
- @config.expects(:set).with(:baz, "bang")
83
- @config.expects(:find_and_execute_task).with("first", :before => :start, :after => :finish)
84
- @config.expects(:find_and_execute_task).with("second", :before => :start, :after => :finish)
85
- @cli.execute!
86
- end
87
-
88
- def test_execute_should_call_load_and_exit_triggers
89
- @cli.options[:actions] = %w(first second)
90
- @config.expects(:find_and_execute_task).with("first", :before => :start, :after => :finish)
91
- @config.expects(:find_and_execute_task).with("second", :before => :start, :after => :finish)
92
- @config.expects(:trigger).never
93
- @config.expects(:trigger).with(:load)
94
- @config.expects(:trigger).with(:exit)
95
- @cli.execute!
96
- end
97
-
98
- def test_execute_should_call_handle_error_when_exceptions_occur
99
- @config.expects(:load).raises(Exception, "boom")
100
- @cli.expects(:handle_error).with { |e,| Exception === e }
101
- @cli.execute!
102
- end
103
-
104
- def test_execute_should_return_config_instance
105
- assert_equal @config, @cli.execute!
106
- end
107
-
108
- def test_instantiate_configuration_should_return_new_configuration_instance
109
- assert_instance_of Capistrano::Configuration, MockCLI.new.instantiate_configuration
110
- end
111
-
112
- def test_handle_error_with_auth_error_should_abort_with_message_including_user_name
113
- @cli.expects(:abort).with { |s| s.include?("jamis") }
114
- @cli.handle_error(Net::SSH::AuthenticationFailed.new("jamis"))
115
- end
116
-
117
- def test_handle_error_with_cap_error_should_abort_with_message
118
- @cli.expects(:abort).with("Wish you were here")
119
- @cli.handle_error(Capistrano::Error.new("Wish you were here"))
120
- end
121
-
122
- def test_handle_error_with_other_errors_should_reraise_error
123
- other_error = Class.new(RuntimeError)
124
- assert_raises(other_error) { @cli.handle_error(other_error.new("boom")) }
125
- end
126
-
127
- def test_class_execute_method_should_call_parse_and_execute_with_ARGV
128
- cli = mock(:execute! => nil)
129
- MockCLI.expects(:parse).with(ARGV).returns(cli)
130
- MockCLI.execute
131
- end
132
- end
@@ -1,139 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../utils"
2
- require 'capistrano/cli/help'
3
-
4
- class CLIHelpTest < Test::Unit::TestCase
5
- class MockCLI
6
- attr_reader :options, :called_original
7
-
8
- def initialize
9
- @options = {}
10
- @called_original = false
11
- end
12
-
13
- def execute_requested_actions(config)
14
- @called_original = config
15
- end
16
-
17
- include Capistrano::CLI::Help
18
- end
19
-
20
- def setup
21
- @cli = MockCLI.new
22
- @cli.options[:verbose] = 0
23
- @ui = stub("ui", :output_cols => 80, :output_rows => 20, :page_at= => nil)
24
- MockCLI.stubs(:ui).returns(@ui)
25
- end
26
-
27
- def test_execute_requested_actions_without_tasks_or_explain_should_call_original
28
- @cli.execute_requested_actions(:config)
29
- @cli.expects(:task_list).never
30
- @cli.expects(:explain_task).never
31
- assert_equal :config, @cli.called_original
32
- end
33
-
34
- def test_execute_requested_actions_with_tasks_should_call_task_list
35
- @cli.options[:tasks] = true
36
- @cli.expects(:task_list).with(:config)
37
- @cli.expects(:explain_task).never
38
- @cli.execute_requested_actions(:config)
39
- assert !@cli.called_original
40
- end
41
-
42
- def test_execute_requested_actions_with_explain_should_call_explain_task
43
- @cli.options[:explain] = "deploy_with_niftiness"
44
- @cli.expects(:task_list).never
45
- @cli.expects(:explain_task).with(:config, "deploy_with_niftiness")
46
- @cli.execute_requested_actions(:config)
47
- assert !@cli.called_original
48
- end
49
-
50
- def test_task_list_with_no_tasks_should_emit_warning
51
- config = mock("config", :task_list => [])
52
- @cli.expects(:warn)
53
- @cli.task_list(config)
54
- end
55
-
56
- def test_task_list_should_query_all_tasks_in_all_namespaces
57
- expected_max_len = 80 - 3 - MockCLI::LINE_PADDING
58
- task_list = [task("c"), task("g", "c:g"), task("b", "c:b"), task("a")]
59
- task_list.each { |t| t.expects(:brief_description).with(expected_max_len).returns(t.fully_qualified_name) }
60
-
61
- config = mock("config")
62
- config.expects(:task_list).with(:all).returns(task_list)
63
- @cli.stubs(:puts)
64
- @cli.task_list(config)
65
- end
66
-
67
- def test_task_list_should_never_use_less_than_MIN_MAX_LEN_chars_for_descriptions
68
- @ui.stubs(:output_cols).returns(20)
69
- t = task("c")
70
- t.expects(:brief_description).with(30).returns("hello")
71
- config = mock("config", :task_list => [t])
72
- @cli.stubs(:puts)
73
- @cli.task_list(config)
74
- end
75
-
76
- def test_task_list_should_not_include_tasks_with_blank_description_or_internal_by_default
77
- t1 = task("c")
78
- t1.expects(:brief_description).returns("hello")
79
- t2 = task("d", "d", "[internal] howdy")
80
- t2.expects(:brief_description).never
81
- t3 = task("e", "e", "")
82
- t3.expects(:brief_description).never
83
-
84
- config = mock("config", :task_list => [t1, t2, t3])
85
- @cli.stubs(:puts)
86
- @cli.expects(:puts).never.with { |s,| (s || "").include?("[internal]") || s =~ /#\s*$/ }
87
- @cli.task_list(config)
88
- end
89
-
90
- def test_task_list_should_include_tasks_with_blank_descriptions_and_internal_when_verbose
91
- t1 = task("c")
92
- t1.expects(:brief_description).returns("hello")
93
- t2 = task("d", "d", "[internal] howdy")
94
- t2.expects(:brief_description).returns("[internal] howdy")
95
- t3 = task("e", "e", "")
96
- t3.expects(:brief_description).returns("")
97
-
98
- config = mock("config", :task_list => [t1, t2, t3])
99
- @cli.options[:verbose] = 1
100
- @cli.stubs(:puts)
101
- @cli.expects(:puts).with { |s,| (s || "").include?("[internal]") || s =~ /#\s*$/ }.at_least_once
102
- @cli.task_list(config)
103
- end
104
-
105
- def test_explain_task_should_warn_if_task_does_not_exist
106
- config = mock("config", :find_task => nil)
107
- @cli.expects(:warn).with { |s,| s =~ /`deploy_with_niftiness'/ }
108
- @cli.explain_task(config, "deploy_with_niftiness")
109
- end
110
-
111
- def test_explain_task_with_task_that_has_no_description_should_emit_stub
112
- t = mock("task", :description => "")
113
- config = mock("config")
114
- config.expects(:find_task).with("deploy_with_niftiness").returns(t)
115
- @cli.stubs(:puts)
116
- @cli.expects(:puts).with("There is no description for this task.")
117
- @cli.explain_task(config, "deploy_with_niftiness")
118
- end
119
-
120
- def test_explain_task_with_task_should_format_description
121
- t = stub("task", :description => "line1\nline2\n\nline3")
122
- config = mock("config", :find_task => t)
123
- @cli.stubs(:puts)
124
- @cli.explain_task(config, "deploy_with_niftiness")
125
- end
126
-
127
- def test_long_help_should_load_and_format_help_txt_file
128
- File.expects(:dirname).returns "a/b/c"
129
- File.expects(:read).with("a/b/c/help.txt").returns("text")
130
- @ui.expects(:say).with("text\n")
131
- @cli.long_help
132
- end
133
-
134
- private
135
-
136
- def task(name, fqn=name, desc="a description")
137
- stub("task", :name => name, :fully_qualified_name => fqn, :description => desc)
138
- end
139
- end
@@ -1,226 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../utils"
2
- require 'capistrano/cli/options'
3
-
4
- class CLIOptionsTest < Test::Unit::TestCase
5
- class ExitException < Exception; end
6
-
7
- class MockCLI
8
- def initialize
9
- @args = []
10
- end
11
-
12
- attr_reader :args
13
-
14
- include Capistrano::CLI::Options
15
- end
16
-
17
- def setup
18
- @cli = MockCLI.new
19
- end
20
-
21
- def test_parse_options_should_require_non_empty_args_list
22
- @cli.stubs(:warn)
23
- @cli.expects(:exit).raises(ExitException)
24
- assert_raises(ExitException) { @cli.parse_options! }
25
- end
26
-
27
- def test_parse_options_with_e_should_set_explain_option
28
- @cli.args << "-e" << "sample"
29
- @cli.parse_options!
30
- assert_equal "sample", @cli.options[:explain]
31
- end
32
-
33
- def test_parse_options_with_f_should_add_recipe_file
34
- @cli.args << "-f" << "deploy"
35
- @cli.parse_options!
36
- assert_equal %w(deploy), @cli.options[:recipes]
37
- end
38
-
39
- def test_parse_options_with_multiple_f_should_add_each_as_recipe_file
40
- @cli.args << "-f" << "deploy" << "-f" << "monitor"
41
- @cli.parse_options!
42
- assert_equal %w(deploy monitor), @cli.options[:recipes]
43
- end
44
-
45
- def test_parse_options_with_H_should_show_verbose_help_and_exit
46
- @cli.expects(:exit).raises(ExitException)
47
- @cli.expects(:long_help)
48
- @cli.args << "-H"
49
- assert_raises(ExitException) { @cli.parse_options! }
50
- end
51
-
52
- def test_parse_options_with_h_should_show_options_and_exit
53
- @cli.expects(:puts).with(@cli.option_parser)
54
- @cli.expects(:exit).raises(ExitException)
55
- @cli.args << "-h"
56
- assert_raises(ExitException) { @cli.parse_options! }
57
- end
58
-
59
- def test_parse_options_with_p_should_prompt_for_password
60
- MockCLI.expects(:password_prompt).returns(:the_password)
61
- @cli.args << "-p"
62
- @cli.parse_options!
63
- assert_equal :the_password, @cli.options[:password]
64
- end
65
-
66
- def test_parse_options_without_p_should_set_proc_for_password
67
- @cli.args << "-e" << "sample"
68
- @cli.parse_options!
69
- assert_instance_of Proc, @cli.options[:password]
70
- end
71
-
72
- def test_parse_options_with_q_should_set_verbose_to_0
73
- @cli.args << "-q"
74
- @cli.parse_options!
75
- assert_equal 0, @cli.options[:verbose]
76
- end
77
-
78
- def test_parse_options_with_S_should_set_pre_vars
79
- @cli.args << "-S" << "foo=bar"
80
- @cli.parse_options!
81
- assert_equal "bar", @cli.options[:pre_vars][:foo]
82
- end
83
-
84
- def test_parse_options_with_s_should_set_vars
85
- @cli.args << "-s" << "foo=bar"
86
- @cli.parse_options!
87
- assert_equal "bar", @cli.options[:vars][:foo]
88
- end
89
-
90
- def test_parse_options_with_T_should_set_tasks_option_and_set_verbose_off
91
- @cli.args << "-T"
92
- @cli.parse_options!
93
- assert @cli.options[:tasks]
94
- assert_equal 0, @cli.options[:verbose]
95
- end
96
-
97
- def test_parse_options_with_V_should_show_version_and_exit
98
- @cli.args << "-V"
99
- @cli.expects(:puts).with { |s| s.include?(Capistrano::Version::STRING) }
100
- @cli.expects(:exit).raises(ExitException)
101
- assert_raises(ExitException) { @cli.parse_options! }
102
- end
103
-
104
- def test_parse_options_with_v_should_set_verbose_to_1
105
- @cli.args << "-v"
106
- @cli.parse_options!
107
- assert_equal 1, @cli.options[:verbose]
108
- end
109
-
110
- def test_parse_options_with_multiple_v_should_set_verbose_accordingly
111
- @cli.args << "-vvvvvvv"
112
- @cli.parse_options!
113
- assert_equal 7, @cli.options[:verbose]
114
- end
115
-
116
- def test_parse_options_without_X_should_set_sysconf
117
- @cli.args << "-v"
118
- @cli.parse_options!
119
- assert @cli.options.key?(:sysconf)
120
- end
121
-
122
- def test_parse_options_with_X_should_unset_sysconf
123
- @cli.args << "-X"
124
- @cli.parse_options!
125
- assert !@cli.options.key?(:sysconf)
126
- end
127
-
128
- def test_parse_options_without_x_should_set_dotfile
129
- @cli.args << "-v"
130
- @cli.parse_options!
131
- assert @cli.options.key?(:dotfile)
132
- end
133
-
134
- def test_parse_options_with_x_should_unset_dotfile
135
- @cli.args << "-x"
136
- @cli.parse_options!
137
- assert !@cli.options.key?(:dotfile)
138
- end
139
-
140
- def test_parse_options_without_q_or_v_should_set_verbose_to_3
141
- @cli.args << "-x"
142
- @cli.parse_options!
143
- assert_equal 3, @cli.options[:verbose]
144
- end
145
-
146
- def test_should_search_for_default_recipes_if_f_not_given
147
- @cli.expects(:look_for_default_recipe_file!)
148
- @cli.args << "-v"
149
- @cli.parse_options!
150
- end
151
-
152
- def test_should_not_search_for_default_recipes_if_f_given
153
- @cli.expects(:look_for_default_recipe_file!).never
154
- @cli.args << "-f" << "hello"
155
- @cli.parse_options!
156
- end
157
-
158
- def test_F_should_search_for_default_recipes_even_if_f_is_given
159
- @cli.expects(:look_for_default_recipe_file!)
160
- @cli.args << "-Ff" << "hello"
161
- @cli.parse_options!
162
- end
163
-
164
- def test_should_extract_env_vars_from_command_line
165
- assert_nil ENV["HELLO"]
166
- assert_nil ENV["ANOTHER"]
167
-
168
- @cli.args << "HELLO=world" << "hello" << "ANOTHER=value"
169
- @cli.parse_options!
170
-
171
- assert_equal "world", ENV["HELLO"]
172
- assert_equal "value", ENV["ANOTHER"]
173
- ensure
174
- ENV["HELLO"] = ENV["ANOTHER"] = nil
175
- end
176
-
177
- def test_remaining_args_should_be_added_to_actions_list
178
- @cli.args << "-v" << "HELLO=world" << "-f" << "foo" << "something" << "else"
179
- @cli.parse_options!
180
- assert_equal %w(something else), @cli.args
181
- ensure
182
- ENV["HELLO"] = nil
183
- end
184
-
185
- def test_search_for_default_recipe_file_should_look_for_Capfile
186
- File.stubs(:file?).returns(false)
187
- File.expects(:file?).with("Capfile").returns(true)
188
- @cli.args << "-v"
189
- @cli.parse_options!
190
- assert_equal %w(Capfile), @cli.options[:recipes]
191
- end
192
-
193
- def test_search_for_default_recipe_file_should_look_for_capfile
194
- File.stubs(:file?).returns(false)
195
- File.expects(:file?).with("capfile").returns(true)
196
- @cli.args << "-v"
197
- @cli.parse_options!
198
- assert_equal %w(capfile), @cli.options[:recipes]
199
- end
200
-
201
- def test_search_for_default_recipe_should_hike_up_the_directory_tree_until_it_finds_default_recipe
202
- File.stubs(:file?).returns(false)
203
- File.expects(:file?).with("capfile").times(2).returns(false,true)
204
- Dir.expects(:pwd).times(3).returns(*%w(/bar/baz /bar/baz /bar))
205
- Dir.expects(:chdir).with("..")
206
- @cli.args << "-v"
207
- @cli.parse_options!
208
- assert_equal %w(capfile), @cli.options[:recipes]
209
- end
210
-
211
- def test_search_for_default_recipe_should_halt_at_root_directory
212
- File.stubs(:file?).returns(false)
213
- Dir.expects(:pwd).times(7).returns(*%w(/bar/baz /bar/baz /bar /bar / / /))
214
- Dir.expects(:chdir).with("..").times(3)
215
- Dir.expects(:chdir).with("/bar/baz")
216
- @cli.args << "-v"
217
- @cli.parse_options!
218
- assert @cli.options[:recipes].empty?
219
- end
220
-
221
- def test_parse_should_instantiate_new_cli_and_call_parse_options
222
- cli = mock("cli", :parse_options! => nil)
223
- MockCLI.expects(:new).with(%w(a b c)).returns(cli)
224
- assert_equal cli, MockCLI.parse(%w(a b c))
225
- end
226
- end
data/test/cli/ui_test.rb DELETED
@@ -1,28 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/../utils"
2
- require 'capistrano/cli/ui'
3
-
4
- class CLIUITest < Test::Unit::TestCase
5
- class MockCLI
6
- include Capistrano::CLI::UI
7
- end
8
-
9
- def test_ui_should_return_highline_instance
10
- assert_instance_of HighLine, MockCLI.ui
11
- end
12
-
13
- def test_password_prompt_should_have_default_prompt_and_set_echo_false
14
- q = mock("question")
15
- q.expects(:echo=).with(false)
16
- ui = mock("ui")
17
- ui.expects(:ask).with("Password: ").yields(q).returns("sayuncle")
18
- MockCLI.expects(:ui).returns(ui)
19
- assert_equal "sayuncle", MockCLI.password_prompt
20
- end
21
-
22
- def test_password_prompt_with_custom_prompt_should_use_custom_prompt
23
- ui = mock("ui")
24
- ui.expects(:ask).with("Give the passphrase: ").returns("sayuncle")
25
- MockCLI.expects(:ui).returns(ui)
26
- assert_equal "sayuncle", MockCLI.password_prompt("Give the passphrase: ")
27
- end
28
- end
data/test/cli_test.rb DELETED
@@ -1,17 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/utils"
2
- require 'capistrano/cli'
3
-
4
- class CLI_Test < Test::Unit::TestCase
5
- def test_options_ui_and_help_modules_should_integrate_successfully_with_configuration
6
- cli = Capistrano::CLI.parse(%w(-T))
7
- cli.expects(:puts).at_least_once
8
- cli.execute!
9
- end
10
-
11
- def test_options_and_execute_modules_should_integrate_successfully_with_configuration
12
- path = "#{File.dirname(__FILE__)}/fixtures/cli_integration.rb"
13
- cli = Capistrano::CLI.parse(%W(-q -f #{path} testing))
14
- config = cli.execute!
15
- assert config[:testing_occurred]
16
- end
17
- end