Class | Spec::Mocks::MessageExpectation |
In: |
lib/spec/mocks/message_expectation.rb
|
Parent: | BaseExpectation |
# File lib/spec/mocks/message_expectation.rb, line 173 173: def any_number_of_times 174: @expected_received_count = :any 175: self 176: end
# File lib/spec/mocks/message_expectation.rb, line 150 150: def at_least(n) 151: set_expected_received_count :at_least, n 152: self 153: end
# File lib/spec/mocks/message_expectation.rb, line 155 155: def at_most(n) 156: set_expected_received_count :at_most, n 157: self 158: end
# File lib/spec/mocks/message_expectation.rb, line 145 145: def exactly(n) 146: set_expected_received_count :exactly, n 147: self 148: end
# File lib/spec/mocks/message_expectation.rb, line 122 122: def matches_name_but_not_args(sym, args) 123: @sym == sym and not @args_expectation.check_args(args) 124: end
# File lib/spec/mocks/message_expectation.rb, line 199 199: def negative_expectation_for?(sym) 200: return false 201: end
# File lib/spec/mocks/message_expectation.rb, line 178 178: def never 179: @expected_received_count = 0 180: self 181: end
# File lib/spec/mocks/message_expectation.rb, line 183 183: def once 184: @expected_received_count = 1 185: self 186: end
# File lib/spec/mocks/message_expectation.rb, line 193 193: def ordered 194: @order_group.register(self) 195: @ordered = true 196: self 197: end
# File lib/spec/mocks/message_expectation.rb, line 160 160: def set_expected_received_count(relativity, n) 161: @at_least = (relativity == :at_least) 162: @at_most = (relativity == :at_most) 163: @expected_received_count = 1 if n == :once 164: @expected_received_count = 2 if n == :twice 165: @expected_received_count = n if n.kind_of? Numeric 166: end
# File lib/spec/mocks/message_expectation.rb, line 168 168: def times 169: #pure sugar 170: self 171: end
# File lib/spec/mocks/message_expectation.rb, line 188 188: def twice 189: @expected_received_count = 2 190: self 191: end
# File lib/spec/mocks/message_expectation.rb, line 126 126: def verify_messages_received 127: return if @expected_received_count == :any 128: return if (@at_least) && (@received_count >= @expected_received_count) 129: return if (@at_most) && (@received_count <= @expected_received_count) 130: return if @expected_received_count == @received_count 131: 132: begin 133: @error_generator.raise_expectation_error @sym, @expected_received_count, @received_count, @args_expectation.args 134: rescue => error 135: error.backtrace.insert(0, @expected_from) 136: Kernel::raise error 137: end 138: end