mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Use do...end for multi-line stub def
This commit is contained in:
parent
6b85bb7ed7
commit
49764e5873
1 changed files with 6 additions and 2 deletions
|
@ -1,12 +1,16 @@
|
||||||
module Spectator
|
module Spectator
|
||||||
abstract class Double
|
abstract class Double
|
||||||
macro stub(definition)
|
macro stub(definition, &block)
|
||||||
delegate {{definition.name.id}}, to: @internal
|
delegate {{definition.name.id}}, to: @internal
|
||||||
|
|
||||||
private class Internal
|
private class Internal
|
||||||
def {{definition.name.id}}({{definition.args.splat}})
|
def {{definition.name.id}}({{definition.args.splat}})
|
||||||
{% if definition.block.is_a?(Nop) %}
|
{% if definition.block.is_a?(Nop) %}
|
||||||
|
{% if block.is_a?(Nop) %}
|
||||||
raise "Stubbed method called without being allowed"
|
raise "Stubbed method called without being allowed"
|
||||||
|
{% else %}
|
||||||
|
{{block.body}}
|
||||||
|
{% end %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{definition.block.body}}
|
{{definition.block.body}}
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
Loading…
Reference in a new issue