forked from capistrano/capistrano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration_test.rb
77 lines (63 loc) · 2.2 KB
/
configuration_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require "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)
process_args = Proc.new do |tree, session, opts|
tree.fallback.command == "echo 'hello world'" &&
session == [:session] &&
opts == { :logger => @config.logger }
end
Capistrano::Command.expects(:process).with(&process_args)
@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