Catch duplicate given blocks with same variable name

This commit is contained in:
Michael Miller 2018-09-06 22:39:40 -06:00
parent 5646a6ebd9
commit cb0ae516ae

View file

@ -110,6 +110,9 @@ module Spectator
macro given(collection, source_file = __FILE__, source_line = __LINE__, &block) macro given(collection, source_file = __FILE__, source_line = __LINE__, &block)
context({{collection}}, {{source_file}}, {{source_line}}, "Given") do context({{collection}}, {{source_file}}, {{source_line}}, "Given") do
{% var_name = block.args.empty? ? "value" : block.args.first %} {% 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 module Locals
@%wrapper : ValueWrapper? @%wrapper : ValueWrapper?