From 7fc25b84c3584a7a25e2ddcdc93d546f345b59c3 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Fri, 29 May 2020 20:06:37 -0600 Subject: [PATCH] Fix bug when using multiple short-hand block expects in one test For instance, this would fail: ``` it "does something" do expect(&.foo).to be_true expect(&.false).to be_false end ``` --- src/spectator/dsl/assertions.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spectator/dsl/assertions.cr b/src/spectator/dsl/assertions.cr index a9f1516..aa94b13 100644 --- a/src/spectator/dsl/assertions.cr +++ b/src/spectator/dsl/assertions.cr @@ -61,7 +61,7 @@ module Spectator # { |__arg0| __arg0.foo } # ``` # The hack used here is to check if it looks like a compiler-generated block. - {% if block.args == ["__arg0".id] && block.body.is_a?(Call) && block.body.id =~ /^__arg0\./ %} + {% if block.args.size == 1 && block.args[0] =~ /^__arg\d+$/ && block.body.is_a?(Call) && block.body.id =~ /^__arg\d+\./ %} # Extract the method name to make it clear to the user what is tested. # The raw block can't be used because it's not clear to the user. {% method_name = block.body.id.split('.')[1..-1].join('.') %}