From f25eb9164f479edf3e55c26fce442e0e19695f54 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 8 Sep 2019 09:58:15 -0600 Subject: [PATCH] Some test creation rewrite --- src/spectator/dsl/structure_dsl.cr | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/spectator/dsl/structure_dsl.cr b/src/spectator/dsl/structure_dsl.cr index dce58d4..05113b6 100644 --- a/src/spectator/dsl/structure_dsl.cr +++ b/src/spectator/dsl/structure_dsl.cr @@ -1416,17 +1416,20 @@ module Spectator::DSL # Create the wrapper class for the test code. {% if block.is_a?(Nop) %} {% if what.is_a?(Call) %} - _spectator_test(Test%example, %run) do + def %run {{what}} end {% else %} {% raise "Unrecognized syntax: `it #{what}`" %} {% end %} {% else %} - _spectator_test(Test%example, %run) {{block}} + def %run + {{block}} + end {% end %} - # TODO + %source = ::Spectator::Source.new({{_source_file}}, {{_source_line}}) + ::Spectator::DSL::Builder.add_example({{what.stringify}}, %source, {{@type.name}}) { |test| test.as({{@type.name}}).%run } end # Creates an example, or a test case.