Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add some more tests to bring code coverage up

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6319 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit b8a1698d3904695ee15adf38d5838a88df1c88a9 1 parent f74ab73
@jamis jamis authored
View
2  Rakefile
@@ -57,4 +57,6 @@ end
desc "Clean up generated directories and files"
task :clean do
rm_rf "pkg"
+ rm_rf "doc"
+ rm_rf "coverage"
end
View
1  lib/capistrano/configuration.rb
@@ -1,6 +1,5 @@
#require 'capistrano/extensions'
require 'capistrano/logger'
-require 'capistrano/utils'
require 'capistrano/configuration/connections'
require 'capistrano/configuration/execution'
View
24 lib/capistrano/utils.rb
@@ -1,24 +0,0 @@
-module Capistrano
- # A helper method for converting a comma-delimited string into an array of
- # roles.
- def self.str2roles(string)
- list = string.split(/,/).map { |s| s.strip.to_sym }
- list.empty? ? nil : list
- end
-
- # Used by third-party task bundles to identify the capistrano configuration
- # that is loading them. It's return value is not reliable in other contexts.
- # If +require_config+ is not false, an exception will be raised if the current
- # configuration is not set.
- def self.configuration(require_config=false)
- warn "[DEPRECATION] use Capistrano::Configuration.instance instead of Capistrano.configuration. (You may be using a Capistrano plugin that is using this deprecated syntax.)"
- Capistrano::Configuration.instance(require_config)
- end
-
- # Used internally by Capistrano to specify the current configuration before
- # loading a third-party task bundle.
- def self.configuration=(config)
- warn "[DEPRECATION] use Capistrano::Configuration.instance= instead of Capistrano.configuration=."
- Capistrano::Configuration.instance = config
- end
-end
View
6 test/cli/options_test.rb
@@ -183,4 +183,10 @@ def test_search_for_default_recipe_file_should_look_for_capfile
@cli.parse_options!
assert_equal %w(capfile), @cli.options[:recipes]
end
+
+ def test_parse_should_instantiate_new_cli_and_call_parse_options
+ cli = mock("cli", :parse_options! => nil)
+ MockCLI.expects(:new).with(%w(a b c)).returns(cli)
+ assert_equal cli, MockCLI.parse(%w(a b c))
+ end
end
View
8 test/command_test.rb
@@ -206,6 +206,14 @@ def test_process_should_ping_all_connections_each_second
assert_nothing_raised { cmd.process! }
end
+ def test_process_should_instantiate_command_and_process!
+ cmd = mock("command", :process! => nil)
+ Capistrano::Command.expects(:new).with("ls -l", %w(a b c), {:foo => "bar"}).yields(:command).returns(cmd)
+ parameter = nil
+ Capistrano::Command.process("ls -l", %w(a b c), :foo => "bar") { |cmd| parameter = cmd }
+ assert_equal :command, parameter
+ end
+
private
def new_channel(closed, status=nil)
View
18 test/configuration/namespace_dsl_test.rb
@@ -233,4 +233,22 @@ def test_task_list_with_all_should_return_all_tasks_under_this_namespace_recursi
assert_equal %w(first outer:inner:third outer:second), @config.task_list(:all).map { |t| t.fully_qualified_name }.sort
end
+
+ def test_namespace_should_respond_to_its_parents_methods
+ @config.namespace(:outer) {}
+ ns = @config.namespaces[:outer]
+ assert ns.respond_to?(:original_initialize_called)
+ end
+
+ def test_namespace_should_delegate_unknown_messages_to_its_parent
+ @config.namespace(:outer) {}
+ ns = @config.namespaces[:outer]
+ assert ns.original_initialize_called
+ end
+
+ def test_namespace_should_not_understand_messages_that_neither_it_nor_its_parent_understands
+ @config.namespace(:outer) {}
+ ns = @config.namespaces[:outer]
+ assert_raises(NoMethodError) { ns.alskdfjlsf }
+ end
end
View
4 test/configuration_test.rb
@@ -1,6 +1,10 @@
require "#{File.dirname(__FILE__)}/utils"
require 'capistrano/configuration'
+# These tests are only for testing the integration of the various components
+# of the Configuration class. To test specific features, please look at the
+# tests under test/configuration.
+
class ConfigurationTest < Test::Unit::TestCase
def setup
@config = Capistrano::Configuration.new
Please sign in to comment.
Something went wrong with that request. Please try again.