diff --git a/src/spectator/dsl/matcher_dsl.cr b/src/spectator/dsl/matcher_dsl.cr index b4a6e1b..2f2fa83 100644 --- a/src/spectator/dsl/matcher_dsl.cr +++ b/src/spectator/dsl/matcher_dsl.cr @@ -41,7 +41,7 @@ module Spectator::DSL # expect(x).to be_a(Int32 | String) # ``` macro be_a(expected) - ::Spectator::Matchers::TypeMatcher({{expected}}).new({{expected.stringify}}, nil) + ::Spectator::Matchers::TypeMatcher({{expected}}).new end end end diff --git a/src/spectator/matchers/type_matcher.cr b/src/spectator/matchers/type_matcher.cr index 2ee10a4..581cb2e 100644 --- a/src/spectator/matchers/type_matcher.cr +++ b/src/spectator/matchers/type_matcher.cr @@ -4,6 +4,12 @@ module Spectator::Matchers # Matcher that tests a value is of a specified type. # The values are compared with the `#is_a?` method. struct TypeMatcher(Expected) < ValueMatcher(Nil) + # Creates the type matcher. + # The `Expected` type param will be used to populate the underlying label. + def initialize + super(Expected.to_s, nil) + end + # Determines whether the matcher is satisfied with the value given to it. # True is returned if the match was successful, false otherwise. def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType