Add predicate method to check for description

This commit is contained in:
Michael Miller 2020-01-02 18:43:30 -07:00
parent ff2cbcd4c7
commit 00fe913d77

View file

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