From 38ec44c9ac50e4f33df6ba45344b9f91d664aebc Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 12 Nov 2019 21:46:33 -0700 Subject: [PATCH] Simplify type resolution code --- src/spectator/dsl/mocks.cr | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/spectator/dsl/mocks.cr b/src/spectator/dsl/mocks.cr index 46e02ed..2a83711 100644 --- a/src/spectator/dsl/mocks.cr +++ b/src/spectator/dsl/mocks.cr @@ -15,10 +15,7 @@ module Spectator::DSL end macro create_double(type_name, name, **stubs) - {% - type = type_name.resolve? - raise "Could not find a double labeled #{name}" unless type - %} + {% type_name.resolve? || raise("Could not find a double labeled #{name}") %} {{type_name}}.new.tap do |%double| {% for name, value in stubs %} @@ -57,10 +54,7 @@ module Spectator::DSL end macro create_null_double(type_name, name, **stubs) - {% - type = type_name.resolve? - raise "Could not find a double labeled #{name}" unless type - %} + {% type_name.resolve? || raise("Could not find a double labeled #{name}") %} {{type_name}}.new(true).tap do |%double| {% for name, value in stubs %}