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
```
This commit is contained in:
Michael Miller 2020-05-29 20:06:37 -06:00
parent 5d8110ec6c
commit 7fc25b84c3

View file

@ -61,7 +61,7 @@ module Spectator
# { |__arg0| __arg0.foo } # { |__arg0| __arg0.foo }
# ``` # ```
# The hack used here is to check if it looks like a compiler-generated block. # 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. # 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. # 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('.') %}