Class | Spec::Mocks::MessageExpectation |
In: |
lib/spec/mocks/message_expectation.rb
|
Parent: | BaseExpectation |
# File lib/spec/mocks/message_expectation.rb, line 169 169: def any_number_of_times(&block) 170: @method_block = block if block 171: @expected_received_count = :any 172: self 173: end
# File lib/spec/mocks/message_expectation.rb, line 154 154: def at_least(n) 155: set_expected_received_count :at_least, n 156: self 157: end
# File lib/spec/mocks/message_expectation.rb, line 159 159: def at_most(n) 160: set_expected_received_count :at_most, n 161: self 162: end
# File lib/spec/mocks/message_expectation.rb, line 149 149: def exactly(n) 150: set_expected_received_count :exactly, n 151: self 152: end
# File lib/spec/mocks/message_expectation.rb, line 125 125: def matches_name_but_not_args(sym, args) 126: @sym == sym and not @args_expectation.check_args(args) 127: 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 175 175: def never 176: @expected_received_count = 0 177: self 178: end
# File lib/spec/mocks/message_expectation.rb, line 180 180: def once(&block) 181: @method_block = block if block 182: @expected_received_count = 1 183: self 184: end
# File lib/spec/mocks/message_expectation.rb, line 192 192: def ordered(&block) 193: @method_block = block if block 194: @order_group.register(self) 195: @ordered = true 196: self 197: end
# File lib/spec/mocks/message_expectation.rb, line 164 164: def times(&block) 165: @method_block = block if block 166: self 167: end
# File lib/spec/mocks/message_expectation.rb, line 186 186: def twice(&block) 187: @method_block = block if block 188: @expected_received_count = 2 189: self 190: end
# File lib/spec/mocks/message_expectation.rb, line 129 129: def verify_messages_received 130: return if @expected_received_count == :any 131: return if (@at_least) && (@received_count >= @expected_received_count) 132: return if (@at_most) && (@received_count <= @expected_received_count) 133: return if @expected_received_count == @received_count 134: 135: begin 136: @error_generator.raise_expectation_error(@sym, @expected_received_count, @received_count, *@args_expectation.args) 137: rescue => error 138: error.backtrace.insert(0, @expected_from) 139: Kernel::raise error 140: end 141: end
# File lib/spec/mocks/message_expectation.rb, line 143 143: def with(*args, &block) 144: @method_block = block if block 145: @args_expectation = ArgumentExpectation.new(args) 146: self 147: end
# File lib/spec/mocks/message_expectation.rb, line 204 204: def set_expected_received_count(relativity, n) 205: @at_least = (relativity == :at_least) 206: @at_most = (relativity == :at_most) 207: @expected_received_count = 1 if n == :once 208: @expected_received_count = 2 if n == :twice 209: @expected_received_count = n if n.kind_of? Numeric 210: end