mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Include predicate arguments in label
This commit is contained in:
parent
36f53d82db
commit
45f0f7f6d1
1 changed files with 15 additions and 3 deletions
|
@ -573,10 +573,22 @@ module Spectator::DSL
|
||||||
# ```
|
# ```
|
||||||
macro method_missing(call)
|
macro method_missing(call)
|
||||||
{% if call.name.starts_with?("be_") %}
|
{% if call.name.starts_with?("be_") %}
|
||||||
{% method_name = call.name[3..-1] %} # Remove be_ prefix.
|
{% method_name = call.name[3..-1] %} # Remove be_ prefix.
|
||||||
::Spectator::Matchers::PredicateMatcher.new({ {{method_name}}: Tuple.new({{call.args.splat}}) }, {{method_name.stringify}})
|
descriptor = { {{method_name}}: Tuple.new({{call.args.splat}}) }
|
||||||
|
label = String::Builder.new({{method_name.stringify}})
|
||||||
|
{% unless call.args.empty? %}
|
||||||
|
label << '('
|
||||||
|
{% for arg, index in call.args %}
|
||||||
|
label << {{arg}}
|
||||||
|
{% if index < call.args.size - 1 %}
|
||||||
|
label << ", "
|
||||||
|
{% end %}
|
||||||
|
{% end %}
|
||||||
|
label << ')'
|
||||||
|
{% end %}
|
||||||
|
::Spectator::Matchers::PredicateMatcher.new(descriptor, label.to_s)
|
||||||
{% else %}
|
{% else %}
|
||||||
{% raise "Undefined local variable or method '#{call}'" %}
|
{% raise "Undefined local variable or method '#{call}'" %}
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue