| Class | MockIt::Mock |
| In: |
lib/rscm/mockit.rb
|
| Parent: | Object |
# File lib/rscm/mockit.rb, line 54
54: def initialize
55: @expected_methods=[]
56: @expected_validation_procs=[]
57: @setup_call_procs={}
58: @unexpected_calls = []
59: end
# File lib/rscm/mockit.rb, line 61
61: def __expect(method, &validation_proc)
62: validation_proc=Proc.new {|*args| nil} if validation_proc.nil?
63: @expected_methods<<method
64: @expected_validation_procs<<validation_proc
65: self
66: end
# File lib/rscm/mockit.rb, line 68
68: def __setup(method, &proc)
69: proc=Proc.new {|*args| nil} if proc.nil?
70: @setup_call_procs[method]=proc
71: self
72: end
# File lib/rscm/mockit.rb, line 74
74: def __verify
75: begin
76: assert_no_unexpected_calls
77: assert_all_expected_methods_called
78: ensure
79: initialize
80: end
81: end
# File lib/rscm/mockit.rb, line 83
83: def method_missing(method, *args, &proc)
84: if(is_expected_call(method))
85: handle_expected_call(method, *args, &proc)
86: elsif(is_setup_call(method))
87: handle_setup_call(method, *args, &proc)
88: else
89: handle_unexpected_call(method)
90: end
91: end