From 3fc625de3f58c86c902e0f2cbc91b17e66f056fc Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Wed, 12 Sep 2018 18:54:46 -0600 Subject: [PATCH] Allow generic types for #described_class and implicit #subject Add runtime check to ensure #described_class is a type name. --- src/spectator/dsl.cr | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/spectator/dsl.cr b/src/spectator/dsl.cr index a6041f7..080a15e 100644 --- a/src/spectator/dsl.cr +++ b/src/spectator/dsl.cr @@ -27,9 +27,12 @@ module Spectator module Locals include {{parent_module}}::Locals - {% if what.is_a?(Path) %} + {% if what.is_a?(Path) || what.is_a?(Generic) %} def described_class - {{what}} + {{what}}.tap do |thing| + raise "#{thing} must be a type name to use #described_class or #subject,\ + but it is a #{typeof(thing)}" unless thing.is_a?(Class) + end end def subject