2005-08-13 14:36:02 -04:00
|
|
|
class Module
|
|
|
|
def const_during(constant, value)
|
|
|
|
if const_defined?(constant)
|
|
|
|
overridden = true
|
|
|
|
saved = const_get(constant)
|
|
|
|
remove_const(constant)
|
|
|
|
end
|
|
|
|
|
|
|
|
const_set(constant, value)
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
if overridden
|
|
|
|
remove_const(constant)
|
|
|
|
const_set(constant, saved)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class MockLogger
|
|
|
|
def info(msg,pfx=nil) end
|
|
|
|
def debug(msg,pfx=nil) end
|
|
|
|
end
|
|
|
|
|
|
|
|
class MockConfiguration < Hash
|
2005-08-30 16:53:32 -04:00
|
|
|
def initialize(*args)
|
|
|
|
super
|
|
|
|
self[:release_path] = "/path/to/releases/version"
|
2005-12-22 15:55:15 -05:00
|
|
|
self[:ssh_options] = {}
|
2005-08-30 16:53:32 -04:00
|
|
|
end
|
|
|
|
|
2005-08-13 14:36:02 -04:00
|
|
|
def logger
|
|
|
|
@logger ||= MockLogger.new
|
|
|
|
end
|
|
|
|
|
2006-01-28 10:58:04 -05:00
|
|
|
def set(variable, value=nil, &block)
|
|
|
|
self[variable] = value
|
|
|
|
end
|
|
|
|
|
|
|
|
def respond_to?(sym)
|
|
|
|
self.has_key?(sym)
|
|
|
|
end
|
|
|
|
|
2005-08-13 14:36:02 -04:00
|
|
|
def method_missing(sym, *args)
|
|
|
|
if args.length == 0
|
|
|
|
self[sym]
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|