mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
more integration tests
git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6325 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
3b79481659
commit
c0e2ee20f9
4 changed files with 50 additions and 2 deletions
|
@ -79,7 +79,7 @@ module Capistrano
|
|||
|
||||
begin
|
||||
push_task_call_frame(task)
|
||||
result = instance_eval(&task.body)
|
||||
result = task.namespace.instance_eval(&task.body)
|
||||
ensure
|
||||
pop_task_call_frame
|
||||
end
|
||||
|
|
|
@ -63,6 +63,13 @@ class ConfigurationExecutionTest < Test::Unit::TestCase
|
|||
assert_equal %w(testing after_testing), @config.state[:trail]
|
||||
end
|
||||
|
||||
def test_execute_task_should_execute_in_scope_of_tasks_parent
|
||||
ns = stub("namespace", :tasks => {}, :default_task => nil, :fully_qualified_name => "ns")
|
||||
ns.expects(:instance_eval)
|
||||
testing = new_task ns, :testing
|
||||
@config.execute_task(testing)
|
||||
end
|
||||
|
||||
def test_transaction_outside_of_task_should_raise_exception
|
||||
assert_raises(ScriptError) { @config.transaction {} }
|
||||
end
|
||||
|
|
|
@ -3,10 +3,11 @@ require 'capistrano/configuration/namespaces'
|
|||
|
||||
class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
|
||||
class MockConfig
|
||||
attr_reader :original_initialize_called
|
||||
attr_reader :original_initialize_called, :options
|
||||
|
||||
def initialize
|
||||
@original_initialize_called = true
|
||||
@options = {}
|
||||
end
|
||||
|
||||
include Capistrano::Configuration::Namespaces
|
||||
|
|
|
@ -26,4 +26,44 @@ class ConfigurationTest < Test::Unit::TestCase
|
|||
|
||||
@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
|
||||
|
|
Loading…
Add table
Reference in a new issue