diff --git a/src/spectator/mocks/double.cr b/src/spectator/mocks/double.cr index 95538e0..716f2c4 100644 --- a/src/spectator/mocks/double.cr +++ b/src/spectator/mocks/double.cr @@ -124,8 +124,8 @@ module Spectator # Handle all methods but only respond to configured messages. # Raises an `UnexpectedMessage` error for non-configures messages. macro method_missing(call) - Log.debug { "Got undefined method " + {{call.stringify}} } - args = ::Spectator::Arguments.capture({{call.args.splat(", ")}}{% if call.named_args %}{{call.named_args.splat}}{% end %}) + Log.debug { "Got undefined method `{{call.name}}({{*call.args}}{% if call.named_args %}{% unless call.args.empty? %}, {% end %}{{*call.named_args}}{% end %}){% if call.block %} { ... }{% end %}`" } + args = ::Spectator::Arguments.capture({{call.args.splat(", ")}}{% if call.named_args %}{{*call.named_args}}{% end %}) call = ::Spectator::MethodCall.new({{call.name.symbolize}}, args) raise ::Spectator::UnexpectedMessage.new("#{_spectator_stubbed_name} received unexpected message :{{call.name}} with #{args}") nil # Necessary for compiler to infer return type as nil. Avoids runtime "can't execute ... `x` has no type errors".