added MemoryUsage and factored out ProcessCondition
[god.git] / test / helper.rb
blobc0812e714c26bf072a39ffe3180ac86b25e8167d
1 require File.join(File.dirname(__FILE__), *%w[.. lib god])
3 require 'test/unit'
4 # require 'mocha'
6 include God
8 module God
9   class ExitCalledError < StandardError
10   end
12   class Base
13     def exit
14       raise ExitCalledError.new("exit called")
15     end
16   end
18   class FakeCondition < Condition
19       
20     def test
21       true
22     end
23   
24   end
25 end
27 # This allows you to be a good OOP citizen and honor encapsulation, but
28 # still make calls to private methods (for testing) by doing
30 #   obj.bypass.private_thingie(arg1, arg2)
32 # Which is easier on the eye than
34 #   obj.send(:private_thingie, arg1, arg2)
36 class Object
37   class Bypass
38     instance_methods.each do |m|
39       undef_method m unless m =~ /^__/
40     end
42     def initialize(ref)
43       @ref = ref
44     end
45   
46     def method_missing(sym, *args)
47       @ref.__send__(sym, *args)
48     end
49   end
51   def bypass
52     Bypass.new(self)
53   end
54 end