mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Improved test coverage for when require is called twice with same args
This commit is contained in:
parent
913e1094d5
commit
3fe29b73dd
2 changed files with 24 additions and 20 deletions
|
@ -140,9 +140,11 @@ module Capistrano
|
|||
def require(*args) #:nodoc:
|
||||
# look to see if this specific configuration instance has ever seen
|
||||
# these arguments to require before
|
||||
if !@loaded_features.include?(args)
|
||||
@loaded_features << args
|
||||
if @loaded_features.include?(args)
|
||||
return false
|
||||
end
|
||||
|
||||
@loaded_features << args
|
||||
begin
|
||||
original_instance, self.class.instance = self.class.instance, self
|
||||
original_feature, self.class.current_feature = self.class.current_feature, args
|
||||
|
@ -159,9 +161,6 @@ module Capistrano
|
|||
self.class.instance = original_instance
|
||||
self.class.current_feature = original_feature
|
||||
end
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -117,6 +117,11 @@ class ConfigurationLoadingTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_require_from_config_should_return_false_when_called_a_second_time_with_same_args
|
||||
assert @config.require "#{File.dirname(__FILE__)}/../fixtures/custom"
|
||||
assert_equal false, @config.require("#{File.dirname(__FILE__)}/../fixtures/custom")
|
||||
end
|
||||
|
||||
def test_require_in_multiple_instances_should_load_recipes_in_each_instance
|
||||
config2 = MockConfig.new
|
||||
@config.require "#{File.dirname(__FILE__)}/../fixtures/custom"
|
||||
|
|
Loading…
Reference in a new issue