mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Minor fixes
This commit is contained in:
parent
b07dca697e
commit
d3ad0963cd
2 changed files with 6 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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 %}
|
||||
|
|
Loading…
Reference in a new issue