From 00fe913d77c7d9ec5131981ffb6189b5216cfd13 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 2 Jan 2020 18:43:30 -0700 Subject: [PATCH] Add predicate method to check for description --- src/spectator/test_wrapper.cr | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/spectator/test_wrapper.cr b/src/spectator/test_wrapper.cr index 7bd756f..79d5265 100644 --- a/src/spectator/test_wrapper.cr +++ b/src/spectator/test_wrapper.cr @@ -8,18 +8,19 @@ module Spectator # Used to instantiate tests and run them. struct TestWrapper # Description the user provided for the test. - getter description + def description + @description || @source.to_s + end # Location of the test in source code. getter source # Creates a wrapper for the test. - def initialize(@description : String, @source : Source, @test : ::SpectatorTest, @runner : TestMethod) + def initialize(@description : String?, @source : Source, @test : ::SpectatorTest, @runner : TestMethod) end - # Creates a wrapper for the test. - def initialize(description : Nil, @source : Source, @test : ::SpectatorTest, @runner : TestMethod) - @description = @source.to_s + def description? + !@description.nil? end def run