Allow generic types for #described_class and implicit #subject

Add runtime check to ensure #described_class is a type name.
This commit is contained in:
Michael Miller 2018-09-12 18:54:46 -06:00
parent 037612d00a
commit 3fc625de3f

View file

@ -27,9 +27,12 @@ module Spectator
module Locals module Locals
include {{parent_module}}::Locals include {{parent_module}}::Locals
{% if what.is_a?(Path) %} {% if what.is_a?(Path) || what.is_a?(Generic) %}
def described_class 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 end
def subject def subject