aboutsummaryrefslogtreecommitdiffstats
path: root/switchtower/test/utils.rb
diff options
context:
space:
mode:
Diffstat (limited to 'switchtower/test/utils.rb')
-rw-r--r--switchtower/test/utils.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/switchtower/test/utils.rb b/switchtower/test/utils.rb
new file mode 100644
index 0000000000..b483f0c005
--- /dev/null
+++ b/switchtower/test/utils.rb
@@ -0,0 +1,36 @@
+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
+ def logger
+ @logger ||= MockLogger.new
+ end
+
+ def method_missing(sym, *args)
+ if args.length == 0
+ self[sym]
+ else
+ super
+ end
+ end
+end