diff --git a/spec/spectator/dsl/mocks/mock_spec.cr b/spec/spectator/dsl/mocks/mock_spec.cr index d636826..a2b67f3 100644 --- a/spec/spectator/dsl/mocks/mock_spec.cr +++ b/spec/spectator/dsl/mocks/mock_spec.cr @@ -11,7 +11,7 @@ Spectator.describe "Mock DSL", :smoke do args[1].as(Int32), args[2].as(Int32), }, - args[3].as(Int32), + args[:kwarg].as(Int32), { x: args[:x].as(Int32), y: args[:y].as(Int32), diff --git a/src/spectator/mocks/stubbable.cr b/src/spectator/mocks/stubbable.cr index ae8d3f4..6f266b9 100644 --- a/src/spectator/mocks/stubbable.cr +++ b/src/spectator/mocks/stubbable.cr @@ -145,7 +145,9 @@ module Spectator {% for arg, i in method.args %}{% if !method.splat_index || i < method.splat_index %}{{arg.internal_name.stringify}}: {{arg.internal_name}}, {% end %}{% end %} ), {% if method.splat_index && (splat = method.args[method.splat_index].internal_name) %}{{splat.symbolize}}, {{splat}},{% end %} - {{method.double_splat}} + ::NamedTuple.new( + {% for arg, i in method.args %}{% if method.splat_index && i > method.splat_index %}{{arg.internal_name.stringify}}: {{arg.internal_name}}, {% end %}{% end %} + ).merge({{method.double_splat}}) ) %call = ::Spectator::MethodCall.new({{method.name.symbolize}}, %args) _spectator_record_call(%call) @@ -245,7 +247,9 @@ module Spectator {% for arg, i in method.args %}{% if !method.splat_index || i < method.splat_index %}{{arg.internal_name.stringify}}: {{arg.internal_name}}, {% end %}{% end %} ), {% if method.splat_index && (splat = method.args[method.splat_index].internal_name) %}{{splat.symbolize}}, {{splat}},{% end %} - {{method.double_splat}} + ::NamedTuple.new( + {% for arg, i in method.args %}{% if method.splat_index && i > method.splat_index %}{{arg.internal_name.stringify}}: {{arg.internal_name}}, {% end %}{% end %} + ).merge({{method.double_splat}}) ) %call = ::Spectator::MethodCall.new({{method.name.symbolize}}, %args) _spectator_record_call(%call)