133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
# File 'lib/http_decoy/minitest.rb', line 133
def assert_received_request(server, method, path, times: nil, body: nil)
entries = server.request_log.for(method, path)
description = "#{method.to_s.upcase} #{path}"
if times
assert_equal times, entries.count,
"expected #{description} to have been received #{times} time(s), " \
"but it was received #{entries.count} time(s)"
else
assert entries.any?, "expected #{description} to have been received, but it was never called"
end
return unless body
assert entries.any? { |e| HttpDecoy::BodyMatcher.matches?(e.body, body) },
"expected #{description} body to match #{body.inspect}, but received: #{entries.map(&:body).inspect}"
end
|