mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Hackish fix for block short-hand syntax
Dunno when this broke or how it ever worked. 😐
This commit is contained in:
parent
27436b4e09
commit
2666f80653
1 changed files with 7 additions and 7 deletions
|
@ -55,9 +55,6 @@ module Spectator::DSL
|
||||||
{% raise "Argument or block must be provided to expect" %}
|
{% raise "Argument or block must be provided to expect" %}
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
# Create a proc to capture the block.
|
|
||||||
%proc = ->({{block.args.splat}}) {{block}}
|
|
||||||
|
|
||||||
# Check if the short-hand method syntax is used.
|
# Check if the short-hand method syntax is used.
|
||||||
# This is a hack, since macros don't get this as a "literal" or something similar.
|
# This is a hack, since macros don't get this as a "literal" or something similar.
|
||||||
# The Crystal compiler will translate:
|
# The Crystal compiler will translate:
|
||||||
|
@ -73,12 +70,15 @@ module Spectator::DSL
|
||||||
# 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('.') %}
|
||||||
%partial = %proc.partial(subject)
|
%proc = ->{ subject.{{method_name.id}} }
|
||||||
%test_block = ::Spectator::TestBlock.create(%partial, {{"#" + method_name}})
|
%test_block = ::Spectator::TestBlock.create(%proc, {{"#" + method_name}})
|
||||||
{% else %}
|
{% elsif block.args.empty? %}
|
||||||
# In this case, it looks like the short-hand method syntax wasn't used.
|
# In this case, it looks like the short-hand method syntax wasn't used.
|
||||||
# Just drop in the proc as-is.
|
# Capture the block as a proc and pass along.
|
||||||
|
%proc = ->{{block}}
|
||||||
%test_block = ::Spectator::TestBlock.create(%proc, {{"`" + block.body.stringify + "`"}})
|
%test_block = ::Spectator::TestBlock.create(%proc, {{"`" + block.body.stringify + "`"}})
|
||||||
|
{% else %}
|
||||||
|
{% raise "Unexpected block arguments in expect call" %}
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
%source = ::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
%source = ::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue