diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr index 736ac91..c9176e6 100644 --- a/spec/spec_helper.cr +++ b/spec/spec_helper.cr @@ -1,11 +1,12 @@ require "../src/spectator" +require "../src/spectator/should" require "./helpers/**" macro it_fails(description = nil, &block) it {{description}} do expect do {{block.body}} - end.to raise_error(Spectator::ExampleFailed) + end.to raise_error(Spectator::ExpectationFailed) end end diff --git a/src/spectator/dsl/matchers.cr b/src/spectator/dsl/matchers.cr index 8d51193..c5ceeab 100644 --- a/src/spectator/dsl/matchers.cr +++ b/src/spectator/dsl/matchers.cr @@ -718,13 +718,13 @@ module Spectator::DSL # expect { subject << :foo }.to change(&.size).by(1) # ``` macro change(&expression) - {% if block.args.size == 1 && block.args[0] =~ /^__arg\d+$/ && block.body.is_a?(Call) && block.body.id =~ /^__arg\d+\./ %} - {% method_name = block.body.id.split('.')[1..-1].join('.') %} + {% if expression.args.size == 1 && expression.args[0] =~ /^__arg\d+$/ && expression.body.is_a?(Call) && expression.body.id =~ /^__arg\d+\./ %} + {% method_name = expression.body.id.split('.')[1..-1].join('.') %} %block = ::Spectator::Block.new({{"#" + method_name}}) do subject.{{method_name.id}} end - {% elsif block.args.empty? %} - %block = ::Spectator::Block.new({{"`" + block.body.stringify + "`"}}) {{block}} + {% elsif expression.args.empty? %} + %block = ::Spectator::Block.new({{"`" + expression.body.stringify + "`"}}) {{expression}} {% else %} {% raise "Unexpected block arguments in 'expect' call" %} {% end %}