Need to use fresh variables in this macro

This commit is contained in:
Michael Miller 2019-08-11 12:55:38 -06:00
parent 5dfcad3cb4
commit 27436b4e09

View file

@ -74,15 +74,15 @@ module Spectator::DSL
# The raw block can't be used because it's not clear to the user. # The raw block can't be used because it's not clear to the user.
{% method_name = block.body.id.split('.')[1..-1].join('.') %} {% method_name = block.body.id.split('.')[1..-1].join('.') %}
%partial = %proc.partial(subject) %partial = %proc.partial(subject)
test_block = ::Spectator::TestBlock.create(%partial, {{"#" + method_name}}) %test_block = ::Spectator::TestBlock.create(%partial, {{"#" + method_name}})
{% else %} {% else %}
# In this case, it looks like the short-hand method syntax wasn't used. # In this case, it looks like the short-hand method syntax wasn't used.
# Just drop in the proc as-is. # Just drop in the proc as-is.
test_block = ::Spectator::TestBlock.create(%proc, {{"`" + block.body.stringify + "`"}}) %test_block = ::Spectator::TestBlock.create(%proc, {{"`" + block.body.stringify + "`"}})
{% end %} {% end %}
source = ::Spectator::Source.new({{_source_file}}, {{_source_line}}) %source = ::Spectator::Source.new({{_source_file}}, {{_source_line}})
::Spectator::Expectations::ExpectationPartial.new(test_block, source) ::Spectator::Expectations::ExpectationPartial.new(%test_block, %source)
end end
# Starts an expectation. # Starts an expectation.