mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Create parameterless initializer for TypeMatcher
This commit is contained in:
parent
e66c0abcfb
commit
419b1322bf
2 changed files with 7 additions and 1 deletions
|
@ -41,7 +41,7 @@ module Spectator::DSL
|
||||||
# expect(x).to be_a(Int32 | String)
|
# expect(x).to be_a(Int32 | String)
|
||||||
# ```
|
# ```
|
||||||
macro be_a(expected)
|
macro be_a(expected)
|
||||||
::Spectator::Matchers::TypeMatcher({{expected}}).new({{expected.stringify}}, nil)
|
::Spectator::Matchers::TypeMatcher({{expected}}).new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,12 @@ module Spectator::Matchers
|
||||||
# Matcher that tests a value is of a specified type.
|
# Matcher that tests a value is of a specified type.
|
||||||
# The values are compared with the `#is_a?` method.
|
# The values are compared with the `#is_a?` method.
|
||||||
struct TypeMatcher(Expected) < ValueMatcher(Nil)
|
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.
|
# Determines whether the matcher is satisfied with the value given to it.
|
||||||
# True is returned if the match was successful, false otherwise.
|
# True is returned if the match was successful, false otherwise.
|
||||||
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
|
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
|
||||||
|
|
Loading…
Reference in a new issue