Use do...end for multi-line stub def

This commit is contained in:
Michael Miller 2019-10-05 22:43:40 -06:00
parent 6b85bb7ed7
commit 49764e5873

View file

@ -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 %}