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
|
||||
abstract class Double
|
||||
macro stub(definition)
|
||||
macro stub(definition, &block)
|
||||
delegate {{definition.name.id}}, to: @internal
|
||||
|
||||
private class Internal
|
||||
def {{definition.name.id}}({{definition.args.splat}})
|
||||
{% if definition.block.is_a?(Nop) %}
|
||||
raise "Stubbed method called without being allowed"
|
||||
{% if block.is_a?(Nop) %}
|
||||
raise "Stubbed method called without being allowed"
|
||||
{% else %}
|
||||
{{block.body}}
|
||||
{% end %}
|
||||
{% else %}
|
||||
{{definition.block.body}}
|
||||
{% end %}
|
||||
|
|
Loading…
Reference in a new issue