1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00
capistrano/test/configuration_test.rb
Jamis Buck c0e2ee20f9 more integration tests
git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6325 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-03-04 22:05:31 +00:00

69 lines
2.1 KiB
Ruby

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
end
def test_connections_execution_loading_namespaces_roles_and_variables_modules_should_integrate_correctly
Capistrano::SSH.expects(:connect).with { |s,c| s.host == "www.capistrano.test" && c == @config }.returns(:session)
Capistrano::Command.expects(:process).with("echo 'hello world'", [:session], :logger => @config.logger)
@config.load do
role :test, "www.capistrano.test"
set :message, "hello world"
namespace :testing do
task :example, :roles => :test do
run "echo '#{message}'"
end
end
end
@config.testing.example
end
def test_tasks_in_nested_namespace_should_be_able_to_call_tasks_in_same_namespace
@config.namespace(:outer) do
task(:first) { set :called_first, true }
namespace(:inner) do
task(:first) { set :called_inner_first, true }
task(:second) { first }
end
end
@config.outer.inner.second
assert !@config[:called_first]
assert @config[:called_inner_first]
end
def test_tasks_in_nested_namespace_should_be_able_to_call_tasks_in_parent_namespace
@config.namespace(:outer) do
task(:first) { set :called_first, true }
namespace(:inner) do
task(:second) { first }
end
end
@config.outer.inner.second
assert @config[:called_first]
end
def test_tasks_in_nested_namespace_should_be_able_to_call_shadowed_tasks_in_parent_namespace
@config.namespace(:outer) do
task(:first) { set :called_first, true }
namespace(:inner) do
task(:first) { set :called_inner_first, true }
task(:second) { parent.first }
end
end
@config.outer.inner.second
assert @config[:called_first]
assert !@config[:called_inner_first]
end
end