From 1219b19d89c60d19ec37531b31e5e22b7680723e Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 28 Feb 2019 15:40:04 -0700 Subject: [PATCH] Support shorthand &.foo(ARGS) syntax --- src/spectator/dsl/example_dsl.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spectator/dsl/example_dsl.cr b/src/spectator/dsl/example_dsl.cr index aad3e9b..87ecc37 100644 --- a/src/spectator/dsl/example_dsl.cr +++ b/src/spectator/dsl/example_dsl.cr @@ -63,9 +63,9 @@ module Spectator::DSL {% if block.args == ["__arg0".id] && block.body.is_a?(Call) && block.body.id =~ /^__arg0\./ %} # 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('.').last %} + {% method_name = block.body.id.split('.')[1..-1].join('.') %} # TODO: Maybe pass the subject in as __arg0 instead of prefixing the method name. - ::Spectator::Expectations::ValueExpectationPartial.new(subject.{{method_name}}, {{"#" + method_name}}, {{_source_file}}, {{_source_line}}) + ::Spectator::Expectations::ValueExpectationPartial.new(subject.{{method_name.id}}, {{"#" + method_name}}, {{_source_file}}, {{_source_line}}) {% else %} # In this case, it looks like the short-hand method syntax wasn't used. # Just drop in the block as-is.