diff --git a/src/spectator/mocks/stubbable.cr b/src/spectator/mocks/stubbable.cr index 6d6d860..8e531b4 100644 --- a/src/spectator/mocks/stubbable.cr +++ b/src/spectator/mocks/stubbable.cr @@ -292,7 +292,12 @@ module Spectator nil {% else %} # The stubbed value was something else entirely and cannot be cast to the return type. - raise TypeCastError.new("#{_spectator_stubbed_name} received message #{ {{call}} } and is attempting to return a `#{%value.class}`, but returned type must be `#{ {{type}} }`.") + %type = begin + %value.class.to_s + rescue + "" + end + raise TypeCastError.new("#{_spectator_stubbed_name} received message #{ {{call}} } and is attempting to return a `#{%type}`, but returned type must be `#{ {{type}} }`.") {% end %} end end