diff --git a/src/spectator/expectations/expectation.cr b/src/spectator/expectations/expectation.cr index 0a11616..5621998 100644 --- a/src/spectator/expectations/expectation.cr +++ b/src/spectator/expectations/expectation.cr @@ -30,12 +30,12 @@ module Spectator::Expectations end # Describes the condition that must be met for the expectation to be satisifed. - private def message : String + private def message @matcher.message(@partial) end # Describes the condition under which the expectation won't be satisifed. - private def negated_message : String + private def negated_message @matcher.negated_message(@partial) end end diff --git a/src/spectator/matchers/case_matcher.cr b/src/spectator/matchers/case_matcher.cr index 842bf3b..46a46b3 100644 --- a/src/spectator/matchers/case_matcher.cr +++ b/src/spectator/matchers/case_matcher.cr @@ -6,19 +6,19 @@ module Spectator::Matchers struct CaseMatcher(ExpectedType) < ValueMatcher(ExpectedType) # 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) : Bool + def match?(partial) expected === partial.actual end # Describes the condition that satisfies the matcher. # This is informational and displayed to the end-user. - def message(partial) : String + def message(partial) "Expected #{partial.label} to semantically equal #{label} (using ===)" end # Describes the condition that won't satsify the matcher. # 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 ===)" end end diff --git a/src/spectator/matchers/empty_matcher.cr b/src/spectator/matchers/empty_matcher.cr index 4dd192f..a4889b5 100644 --- a/src/spectator/matchers/empty_matcher.cr +++ b/src/spectator/matchers/empty_matcher.cr @@ -11,19 +11,19 @@ module Spectator::Matchers # 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) : Bool + def match?(partial) partial.actual.empty? end # Describes the condition that satisfies the matcher. # This is informational and displayed to the end-user. - def message(partial) : String + def message(partial) "Expected #{partial.label} to be empty" end # Describes the condition that won't satsify the matcher. # 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" end end diff --git a/src/spectator/matchers/equality_matcher.cr b/src/spectator/matchers/equality_matcher.cr index d5da3f7..e883e7c 100644 --- a/src/spectator/matchers/equality_matcher.cr +++ b/src/spectator/matchers/equality_matcher.cr @@ -6,19 +6,19 @@ module Spectator::Matchers struct EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType) # 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) : Bool + def match?(partial) partial.actual == expected end # Describes the condition that satisfies the matcher. # This is informational and displayed to the end-user. - def message(partial) : String + def message(partial) "Expected #{partial.label} to equal #{label} (using ==)" end # Describes the condition that won't satsify the matcher. # 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 ==)" end end diff --git a/src/spectator/matchers/greater_than_equal_matcher.cr b/src/spectator/matchers/greater_than_equal_matcher.cr index 046e13d..90c552f 100644 --- a/src/spectator/matchers/greater_than_equal_matcher.cr +++ b/src/spectator/matchers/greater_than_equal_matcher.cr @@ -6,19 +6,19 @@ module Spectator::Matchers struct GreaterThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType) # 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) : Bool + def match?(partial) partial.actual >= expected end # Describes the condition that satisfies the matcher. # 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 >=)" end # Describes the condition that won't satsify the matcher. # 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 >=)" end end diff --git a/src/spectator/matchers/greater_than_matcher.cr b/src/spectator/matchers/greater_than_matcher.cr index 538cbe6..daffca7 100644 --- a/src/spectator/matchers/greater_than_matcher.cr +++ b/src/spectator/matchers/greater_than_matcher.cr @@ -6,19 +6,19 @@ module Spectator::Matchers struct GreaterThanMatcher(ExpectedType) < ValueMatcher(ExpectedType) # 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) : Bool + def match?(partial) partial.actual > expected end # Describes the condition that satisfies the matcher. # 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 >)" end # Describes the condition that won't satsify the matcher. # 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 >)" end end diff --git a/src/spectator/matchers/inequality_matcher.cr b/src/spectator/matchers/inequality_matcher.cr index f17319b..029eade 100644 --- a/src/spectator/matchers/inequality_matcher.cr +++ b/src/spectator/matchers/inequality_matcher.cr @@ -6,19 +6,19 @@ module Spectator::Matchers struct InequalityMatcher(ExpectedType) < ValueMatcher(ExpectedType) # 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) : Bool + def match?(partial) partial.actual != expected end # Describes the condition that satisfies the matcher. # This is informational and displayed to the end-user. - def message(partial) : String + def message(partial) "Expected #{partial.label} to not equal #{label} (using !=)" end # Describes the condition that won't satsify the matcher. # 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 !=)" end end diff --git a/src/spectator/matchers/less_than_equal_matcher.cr b/src/spectator/matchers/less_than_equal_matcher.cr index a399088..692ec55 100644 --- a/src/spectator/matchers/less_than_equal_matcher.cr +++ b/src/spectator/matchers/less_than_equal_matcher.cr @@ -6,19 +6,19 @@ module Spectator::Matchers struct LessThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType) # 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) : Bool + def match?(partial) partial.actual <= expected end # Describes the condition that satisfies the matcher. # 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 <=)" end # Describes the condition that won't satsify the matcher. # 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 <=)" end end diff --git a/src/spectator/matchers/less_than_matcher.cr b/src/spectator/matchers/less_than_matcher.cr index b82a50a..b7120cd 100644 --- a/src/spectator/matchers/less_than_matcher.cr +++ b/src/spectator/matchers/less_than_matcher.cr @@ -6,19 +6,19 @@ module Spectator::Matchers struct LessThanMatcher(ExpectedType) < ValueMatcher(ExpectedType) # 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) : Bool + def match?(partial) partial.actual < expected end # Describes the condition that satisfies the matcher. # 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 <)" end # Describes the condition that won't satsify the matcher. # 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 <)" end end diff --git a/src/spectator/matchers/nil_matcher.cr b/src/spectator/matchers/nil_matcher.cr index 1601857..d40ed1e 100644 --- a/src/spectator/matchers/nil_matcher.cr +++ b/src/spectator/matchers/nil_matcher.cr @@ -11,19 +11,19 @@ module Spectator::Matchers # 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) : Bool + def match?(partial) partial.actual.nil? end # Describes the condition that satisfies the matcher. # This is informational and displayed to the end-user. - def message(partial) : String + def message(partial) "Expected #{partial.label} to be nil" end # Describes the condition that won't satsify the matcher. # 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" end end diff --git a/src/spectator/matchers/range_matcher.cr b/src/spectator/matchers/range_matcher.cr index 5a28dc5..8351f8f 100644 --- a/src/spectator/matchers/range_matcher.cr +++ b/src/spectator/matchers/range_matcher.cr @@ -8,19 +8,19 @@ module Spectator::Matchers struct RangeMatcher(ExpectedType) < ValueMatcher(ExpectedType) # 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) : Bool + def match?(partial) @expected.includes?(partial.actual) end # Describes the condition that satisfies the matcher. # This is informational and displayed to the end-user. - def message(partial) : String + def message(partial) "Expected #{partial.label} to be in #{label}" end # Describes the condition that won't satsify the matcher. # 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}" end diff --git a/src/spectator/matchers/regex_matcher.cr b/src/spectator/matchers/regex_matcher.cr index 80d4fdf..9993401 100644 --- a/src/spectator/matchers/regex_matcher.cr +++ b/src/spectator/matchers/regex_matcher.cr @@ -6,19 +6,19 @@ module Spectator::Matchers struct RegexMatcher(ExpectedType) < ValueMatcher(ExpectedType) # 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) : Bool + def match?(partial) !!(partial.actual =~ expected) end # Describes the condition that satisfies the matcher. # This is informational and displayed to the end-user. - def message(partial) : String + def message(partial) "Expected #{partial.label} to match #{label} (using =~)" end # Describes the condition that won't satsify the matcher. # 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 =~)" end end diff --git a/src/spectator/matchers/truthy_matcher.cr b/src/spectator/matchers/truthy_matcher.cr index f7c8444..102af74 100644 --- a/src/spectator/matchers/truthy_matcher.cr +++ b/src/spectator/matchers/truthy_matcher.cr @@ -18,20 +18,20 @@ module Spectator::Matchers # 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) : Bool + def match?(partial) # Cast value to truthy value and compare. @expected == !!partial.actual end # Describes the condition that satisfies the matcher. # This is informational and displayed to the end-user. - def message(partial) : String + def message(partial) "Expected #{partial.label} to be #{label}" end # Describes the condition that won't satsify the matcher. # 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}" end diff --git a/src/spectator/matchers/type_matcher.cr b/src/spectator/matchers/type_matcher.cr index 3c07629..6c94b27 100644 --- a/src/spectator/matchers/type_matcher.cr +++ b/src/spectator/matchers/type_matcher.cr @@ -12,19 +12,19 @@ module Spectator::Matchers # 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) : Bool + def match?(partial) partial.actual.is_a?(Expected) end # Describes the condition that satisfies the matcher. # This is informational and displayed to the end-user. - def message(partial) : String + def message(partial) "Expected #{partial.label} to be a #{label}" end # Describes the condition that won't satsify the matcher. # 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}" end end