From cb0ae516ae27102bb92bde191b6e798670eee7bc Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 6 Sep 2018 22:39:40 -0600 Subject: [PATCH] Catch duplicate given blocks with same variable name --- src/spectator/dsl.cr | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/spectator/dsl.cr b/src/spectator/dsl.cr index ce8d5f1..96590d8 100644 --- a/src/spectator/dsl.cr +++ b/src/spectator/dsl.cr @@ -110,6 +110,9 @@ module Spectator macro given(collection, source_file = __FILE__, source_line = __LINE__, &block) context({{collection}}, {{source_file}}, {{source_line}}, "Given") do {% var_name = block.args.empty? ? "value" : block.args.first %} + {% if GIVEN_VARIABLES.find { |v| v[0].id == var_name.id } %} + {% raise "Duplicate given variable name \"#{var_name.id}\"" %} + {% end %} module Locals @%wrapper : ValueWrapper?