public
Description: Remote multi-server automation tool
Homepage: http://www.capify.org
Clone URL: git://github.com/jamis/capistrano.git
Search Repo:
Make sure the CLI components integrate nicely. Make sure the Configuration 
components integrate nicely.


git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6321 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
jamis (author)
Sun Mar 04 13:34:35 -0800 2007
commit  3b79481659678c7b9ef9d5ac2f2ed2c942e264b9
tree    4270ee31a786bde48e4c1bc6379b5c5b01ec3888
parent  b8a1698d3904695ee15adf38d5838a88df1c88a9
...
18
19
20
 
 
21
22
23
...
26
27
28
 
 
29
30
31
...
18
19
20
21
22
23
24
25
...
28
29
30
31
32
33
34
35
0
@@ -18,6 +18,8 @@ module Capistrano
0
       # Using the options build when the command-line was parsed, instantiate
0
       # a new Capistrano configuration, initialize it, and execute the
0
       # requested actions.
0
+ #
0
+ # Returns the Configuration instance used, if successful.
0
       def execute!
0
         config = instantiate_configuration
0
         config.logger.level = options[:verbose]
0
@@ -26,6 +28,8 @@ module Capistrano
0
         load_recipes(config)
0
 
0
         execute_requested_actions(config)
0
+
0
+ config
0
       rescue Exception => error
0
         handle_error(error)
0
       end
...
89
90
91
92
 
93
94
95
...
89
90
91
 
92
93
94
95
0
@@ -89,7 +89,7 @@ module Capistrano
0
 
0
         if !task_already_defined
0
           metaclass = class << self; self; end
0
- metaclass.send(:define_method, name) { execute_task(name, self) }
0
+ metaclass.send(:define_method, name) { execute_task(tasks[name]) }
0
         end
0
       end
0
 
...
89
90
91
 
 
 
 
92
93
94
...
89
90
91
92
93
94
95
96
97
98
0
@@ -89,6 +89,10 @@ class CLIExecuteTest < Test::Unit::TestCase
0
     @cli.execute!
0
   end
0
 
0
+ def test_execute_should_return_config_instance
0
+ assert_equal @config, @cli.execute!
0
+ end
0
+
0
   def test_instantiate_configuration_should_return_new_configuration_instance
0
     assert_instance_of Capistrano::Configuration, MockCLI.new.instantiate_configuration
0
   end
...
2
3
4
5
6
 
 
 
 
7
8
9
10
 
 
 
 
 
11
12
...
2
3
4
 
 
5
6
7
8
9
10
 
 
11
12
13
14
15
16
17
0
@@ -2,11 +2,16 @@ require "#{File.dirname(__FILE__)}/utils"
0
 require 'capistrano/cli'
0
 
0
 class CLI_Test < Test::Unit::TestCase
0
- def setup
0
- @cli = Capistrano::CLI.new([])
0
+ def test_options_ui_and_help_modules_should_integrate_successfully_with_configuration
0
+ cli = Capistrano::CLI.parse(%w(-T))
0
+ cli.expects(:puts).at_least_once
0
+ cli.execute!
0
   end
0
 
0
- def test_flunk
0
- flunk
0
+ def test_options_and_execute_modules_should_integrate_successfully_with_configuration
0
+ path = "#{File.dirname(__FILE__)}/fixtures/cli_integration.rb"
0
+ cli = Capistrano::CLI.parse(%W(-q -f #{path} testing))
0
+ config = cli.execute!
0
+ assert config[:testing_occurred]
0
   end
0
 end
...
120
121
122
 
 
 
 
 
 
123
124
125
...
120
121
122
123
124
125
126
127
128
129
130
131
0
@@ -120,6 +120,12 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
0
     assert @config.methods.include?("original")
0
   end
0
 
0
+ def test_calling_defined_task_should_delegate_to_execute_task
0
+ @config.task(:original) { puts "foo" }
0
+ @config.expects(:execute_task).with(@config.tasks[:original])
0
+ @config.original
0
+ end
0
+
0
   def test_role_inside_namespace_should_raise_error
0
     assert_raises(NotImplementedError) do
0
       @config.namespace(:outer) do
...
10
11
12
13
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
16
...
10
11
12
 
 
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
0
@@ -10,7 +10,20 @@ class ConfigurationTest < Test::Unit::TestCase
0
     @config = Capistrano::Configuration.new
0
   end
0
 
0
- def test_flunk
0
- flunk
0
+ def test_connections_execution_loading_namespaces_roles_and_variables_modules_should_integrate_correctly
0
+ Capistrano::SSH.expects(:connect).with { |s,c| s.host == "www.capistrano.test" && c == @config }.returns(:session)
0
+ Capistrano::Command.expects(:process).with("echo 'hello world'", [:session], :logger => @config.logger)
0
+
0
+ @config.load do
0
+ role :test, "www.capistrano.test"
0
+ set :message, "hello world"
0
+ namespace :testing do
0
+ task :example, :roles => :test do
0
+ run "echo '#{message}'"
0
+ end
0
+ end
0
+ end
0
+
0
+ @config.testing.example
0
   end
0
 end

Comments

    No one has commented yet.