diff --git a/src/spectator/matchers/have_predicate_matcher.cr b/src/spectator/matchers/have_predicate_matcher.cr index 12902bd..55416b5 100644 --- a/src/spectator/matchers/have_predicate_matcher.cr +++ b/src/spectator/matchers/have_predicate_matcher.cr @@ -17,7 +17,7 @@ module Spectator::Matchers # Actually performs the test against the expression. def match(actual : Expression(T)) : MatchData forall T snapshot = snapshot_values(actual.value) - if match?(snapshot) + if values_match?(snapshot) SuccessfulMatchData.new(description) else FailedMatchData.new(description, "#{actual.label} does not have #{expected.label}", values(snapshot).to_a) @@ -28,13 +28,18 @@ module Spectator::Matchers # A successful match with `#match` should normally fail for this method, and vice-versa. def negated_match(actual : Expression(T)) : MatchData forall T snapshot = snapshot_values(actual.value) - if match?(snapshot) + if values_match?(snapshot) FailedMatchData.new(description, "#{actual.label} has #{expected.label}", values(snapshot).to_a) else SuccessfulMatchData.new(description) end end + def match?(actual : Expression(T)) : Bool forall T + snapshot = snapshot_values(actual.value) + values_match?(snapshot) + end + # Message displayed when the matcher isn't satisfied. # # This is only called when `#match?` returns false. @@ -69,7 +74,7 @@ module Spectator::Matchers end # Checks if all predicate methods from the snapshot of them are satisfied. - private def match?(snapshot) : Bool + private def values_match?(snapshot) : Bool # Test each predicate and immediately return false if one is false. {% for attribute in ExpectedType.keys %} return false unless snapshot[{{attribute.symbolize}}] diff --git a/src/spectator/mocks/exception_method_stub.cr b/src/spectator/mocks/exception_method_stub.cr index ce34b64..55025fa 100644 --- a/src/spectator/mocks/exception_method_stub.cr +++ b/src/spectator/mocks/exception_method_stub.cr @@ -7,7 +7,7 @@ module Spectator::Mocks super(name, location, args) end - def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT + def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT raise @exception end end diff --git a/src/spectator/mocks/multi_value_method_stub.cr b/src/spectator/mocks/multi_value_method_stub.cr index 944e985..56198d1 100644 --- a/src/spectator/mocks/multi_value_method_stub.cr +++ b/src/spectator/mocks/multi_value_method_stub.cr @@ -10,7 +10,7 @@ module Spectator::Mocks raise ArgumentError.new("Values must have at least one item") if @values.size < 1 end - def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT + def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT value = @values[@index] @index += 1 if @index < @values.size - 1 value diff --git a/src/spectator/mocks/nil_method_stub.cr b/src/spectator/mocks/nil_method_stub.cr index 38b1aab..129913c 100644 --- a/src/spectator/mocks/nil_method_stub.cr +++ b/src/spectator/mocks/nil_method_stub.cr @@ -4,7 +4,7 @@ require "./value_method_stub" module Spectator::Mocks class NilMethodStub < GenericMethodStub(Nil) - def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT + def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT nil end diff --git a/src/spectator/mocks/original_method_stub.cr b/src/spectator/mocks/original_method_stub.cr index 041325a..414dfc0 100644 --- a/src/spectator/mocks/original_method_stub.cr +++ b/src/spectator/mocks/original_method_stub.cr @@ -3,7 +3,7 @@ require "./generic_method_stub" module Spectator::Mocks class OriginalMethodStub < GenericMethodStub(Nil) - def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT + def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT yield end end diff --git a/src/spectator/mocks/proc_method_stub.cr b/src/spectator/mocks/proc_method_stub.cr index a72eb3c..e08880f 100644 --- a/src/spectator/mocks/proc_method_stub.cr +++ b/src/spectator/mocks/proc_method_stub.cr @@ -11,7 +11,7 @@ module Spectator::Mocks ProcMethodStub.new(name, location, block, args) end - def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT + def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT @proc.call end end diff --git a/src/spectator/mocks/value_method_stub.cr b/src/spectator/mocks/value_method_stub.cr index cda6b22..a7bf1c5 100644 --- a/src/spectator/mocks/value_method_stub.cr +++ b/src/spectator/mocks/value_method_stub.cr @@ -7,7 +7,7 @@ module Spectator::Mocks super(name, location, args) end - def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT + def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT @value end end diff --git a/src/spectator/null_node_filter.cr b/src/spectator/null_node_filter.cr index cee8736..b7d37d8 100644 --- a/src/spectator/null_node_filter.cr +++ b/src/spectator/null_node_filter.cr @@ -9,7 +9,7 @@ module Spectator end # Checks whether the node satisfies the filter. - def includes?(_node) : Bool + def includes?(node) : Bool @match end end