Remove unecessary type restrictions

This commit is contained in:
Michael Miller 2019-01-31 13:52:41 -07:00
parent a53bafe333
commit e2779822b5
14 changed files with 41 additions and 41 deletions

View file

@ -30,12 +30,12 @@ module Spectator::Expectations
end end
# Describes the condition that must be met for the expectation to be satisifed. # Describes the condition that must be met for the expectation to be satisifed.
private def message : String private def message
@matcher.message(@partial) @matcher.message(@partial)
end end
# Describes the condition under which the expectation won't be satisifed. # Describes the condition under which the expectation won't be satisifed.
private def negated_message : String private def negated_message
@matcher.negated_message(@partial) @matcher.negated_message(@partial)
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct CaseMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct CaseMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# 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) : Bool def match?(partial)
expected === partial.actual expected === partial.actual
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to semantically equal #{label} (using ===)" "Expected #{partial.label} to semantically equal #{label} (using ===)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to not semantically equal #{label} (using ===)" "Expected #{partial.label} to not semantically equal #{label} (using ===)"
end end
end end

View file

@ -11,19 +11,19 @@ module Spectator::Matchers
# 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) : Bool def match?(partial)
partial.actual.empty? partial.actual.empty?
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to be empty" "Expected #{partial.label} to be empty"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to not be empty" "Expected #{partial.label} to not be empty"
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# 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) : Bool def match?(partial)
partial.actual == expected partial.actual == expected
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to equal #{label} (using ==)" "Expected #{partial.label} to equal #{label} (using ==)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to not equal #{label} (using ==)" "Expected #{partial.label} to not equal #{label} (using ==)"
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct GreaterThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct GreaterThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# 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) : Bool def match?(partial)
partial.actual >= expected partial.actual >= expected
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to be greater than or equal to #{label} (using >=)" "Expected #{partial.label} to be greater than or equal to #{label} (using >=)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to not be greater than or equal to #{label} (using >=)" "Expected #{partial.label} to not be greater than or equal to #{label} (using >=)"
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct GreaterThanMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct GreaterThanMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# 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) : Bool def match?(partial)
partial.actual > expected partial.actual > expected
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to be greater than #{label} (using >)" "Expected #{partial.label} to be greater than #{label} (using >)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to not be greater than #{label} (using >)" "Expected #{partial.label} to not be greater than #{label} (using >)"
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct InequalityMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct InequalityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# 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) : Bool def match?(partial)
partial.actual != expected partial.actual != expected
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to not equal #{label} (using !=)" "Expected #{partial.label} to not equal #{label} (using !=)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to equal #{label} (using !=)" "Expected #{partial.label} to equal #{label} (using !=)"
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct LessThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct LessThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# 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) : Bool def match?(partial)
partial.actual <= expected partial.actual <= expected
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to be less than or equal to #{label} (using <=)" "Expected #{partial.label} to be less than or equal to #{label} (using <=)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to not be less than or equal to #{label} (using <=)" "Expected #{partial.label} to not be less than or equal to #{label} (using <=)"
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct LessThanMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct LessThanMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# 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) : Bool def match?(partial)
partial.actual < expected partial.actual < expected
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to be less than #{label} (using <)" "Expected #{partial.label} to be less than #{label} (using <)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to not be less than #{label} (using <)" "Expected #{partial.label} to not be less than #{label} (using <)"
end end
end end

View file

@ -11,19 +11,19 @@ module Spectator::Matchers
# 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) : Bool def match?(partial)
partial.actual.nil? partial.actual.nil?
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to be nil" "Expected #{partial.label} to be nil"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to not be nil" "Expected #{partial.label} to not be nil"
end end
end end

View file

@ -8,19 +8,19 @@ module Spectator::Matchers
struct RangeMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct RangeMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# 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) : Bool def match?(partial)
@expected.includes?(partial.actual) @expected.includes?(partial.actual)
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to be in #{label}" "Expected #{partial.label} to be in #{label}"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to not be in #{label}" "Expected #{partial.label} to not be in #{label}"
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct RegexMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct RegexMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# 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) : Bool def match?(partial)
!!(partial.actual =~ expected) !!(partial.actual =~ expected)
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to match #{label} (using =~)" "Expected #{partial.label} to match #{label} (using =~)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to not match #{label} (using =~)" "Expected #{partial.label} to not match #{label} (using =~)"
end end
end end

View file

@ -18,20 +18,20 @@ module Spectator::Matchers
# 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) : Bool def match?(partial)
# Cast value to truthy value and compare. # Cast value to truthy value and compare.
@expected == !!partial.actual @expected == !!partial.actual
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to be #{label}" "Expected #{partial.label} to be #{label}"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to not be #{label}" "Expected #{partial.label} to not be #{label}"
end end

View file

@ -12,19 +12,19 @@ module Spectator::Matchers
# 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) : Bool def match?(partial)
partial.actual.is_a?(Expected) partial.actual.is_a?(Expected)
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial) : String def message(partial)
"Expected #{partial.label} to be a #{label}" "Expected #{partial.label} to be a #{label}"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial) : String def negated_message(partial)
"Expected #{partial.label} to not be a #{label}" "Expected #{partial.label} to not be a #{label}"
end end
end end