Better compiler error for wrong argument type passed to mock

This commit is contained in:
Michael Miller 2022-06-01 22:23:39 -06:00
parent 8fbcbe8b73
commit effad28559
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF

View file

@ -190,6 +190,7 @@ module Spectator::DSL
end
macro mock(type, **value_methods, &block)
{% raise "First argument of `mock` must be a type name, not #{type}" unless type.is_a?(Path) || type.is_a?(Generic) || type.is_a?(Union) || type.is_a?(Metaclass) || type.is_a?(TypeNode) %}
{% begin %}
{% if @def %}new_mock{% else %}def_mock{% end %}({{type}}, {{**value_methods}}){% if block %} do
{{block.body}}