| Class | Spec::Mocks::MessageExpectation |
| In: |
lib/spec/mocks/message_expectation.rb
|
| Parent: | BaseExpectation |
# File lib/spec/mocks/message_expectation.rb, line 180
180: def any_number_of_times(&block)
181: @method_block = block if block
182: @expected_received_count = :any
183: self
184: end
# File lib/spec/mocks/message_expectation.rb, line 165
165: def at_least(n)
166: set_expected_received_count :at_least, n
167: self
168: end
# File lib/spec/mocks/message_expectation.rb, line 170
170: def at_most(n)
171: set_expected_received_count :at_most, n
172: self
173: end
# File lib/spec/mocks/message_expectation.rb, line 160
160: def exactly(n)
161: set_expected_received_count :exactly, n
162: self
163: end
# File lib/spec/mocks/message_expectation.rb, line 136
136: def matches_name_but_not_args(sym, args)
137: @sym == sym and not @args_expectation.check_args(args)
138: end
# File lib/spec/mocks/message_expectation.rb, line 210
210: def negative_expectation_for?(sym)
211: return false
212: end
# File lib/spec/mocks/message_expectation.rb, line 186
186: def never
187: @expected_received_count = 0
188: self
189: end
# File lib/spec/mocks/message_expectation.rb, line 191
191: def once(&block)
192: @method_block = block if block
193: @expected_received_count = 1
194: self
195: end
# File lib/spec/mocks/message_expectation.rb, line 203
203: def ordered(&block)
204: @method_block = block if block
205: @order_group.register(self)
206: @ordered = true
207: self
208: end
# File lib/spec/mocks/message_expectation.rb, line 175
175: def times(&block)
176: @method_block = block if block
177: self
178: end
# File lib/spec/mocks/message_expectation.rb, line 197
197: def twice(&block)
198: @method_block = block if block
199: @expected_received_count = 2
200: self
201: end
# File lib/spec/mocks/message_expectation.rb, line 140
140: def verify_messages_received
141: return if @expected_received_count == :any
142: return if (@at_least) && (@received_count >= @expected_received_count)
143: return if (@at_most) && (@received_count <= @expected_received_count)
144: return if @expected_received_count == @received_count
145:
146: begin
147: @error_generator.raise_expectation_error(@sym, @expected_received_count, @received_count, *@args_expectation.args)
148: rescue => error
149: error.backtrace.insert(0, @expected_from)
150: Kernel::raise error
151: end
152: end
# File lib/spec/mocks/message_expectation.rb, line 154
154: def with(*args, &block)
155: @method_block = block if block
156: @args_expectation = ArgumentExpectation.new(args)
157: self
158: end
# File lib/spec/mocks/message_expectation.rb, line 215
215: def set_expected_received_count(relativity, n)
216: @at_least = (relativity == :at_least)
217: @at_most = (relativity == :at_most)
218: @expected_received_count = 1 if n == :once
219: @expected_received_count = 2 if n == :twice
220: @expected_received_count = n if n.kind_of? Numeric
221: end