30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/rspec/bash/mocks/script_message_expectation.rb', line 30
def verify_messages_received(script)
type, expected_count = *@double.expected_call_count
actual_count = @double.call_count(script)
report = lambda {
@error_generator.raise_expectation_error(
@display_name,
expected_count,
::RSpec::Mocks::ArgumentListMatcher::MATCH_ALL,
actual_count,
nil,
Array(@double.to_s),
@backtrace_line
)
}
case type
when :at_least
report[] if actual_count < expected_count
when :at_most
report[] if actual_count > expected_count
when :exactly
report[] if actual_count != expected_count
else
fail "Unrecognized call-count quantifier \"#{type}\""
end
@double.call_args(script).tap do |actual_args|
@double.expected_calls.each_with_index do |args, index|
expected = args
actual = actual_args[index]
if actual != expected
@error_generator.raise_unexpected_message_args_error(
self,
actual_args.map { |x| Array(x) },
)
break
end
end
end
end
|