From 70391b2d31cbe70fd2921d0bf988c3ba8903c027 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 7 Jul 2022 18:10:21 -0600 Subject: [PATCH] Fix warnings from Crystal 1.5.0 regarding positional parameters --- src/spectator/matchers/have_predicate_matcher.cr | 11 ++++++++--- src/spectator/mocks/double.cr | 4 ++-- src/spectator/mocks/null_stub.cr | 2 +- src/spectator/mocks/value_stub.cr | 2 +- src/spectator/null_node_filter.cr | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) 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/double.cr b/src/spectator/mocks/double.cr index 8646ef8..d7f72fd 100644 --- a/src/spectator/mocks/double.cr +++ b/src/spectator/mocks/double.cr @@ -153,7 +153,7 @@ module Spectator yield end - private def _spectator_stub_fallback(call : MethodCall, _type, &) + private def _spectator_stub_fallback(call : MethodCall, type, &) _spectator_stub_fallback(call) { yield } end @@ -167,7 +167,7 @@ module Spectator raise UnexpectedMessage.new("#{_spectator_stubbed_name} received unexpected message #{call}") end - private def _spectator_abstract_stub_fallback(call : MethodCall, _type) + private def _spectator_abstract_stub_fallback(call : MethodCall, type) _spectator_abstract_stub_fallback(call) end diff --git a/src/spectator/mocks/null_stub.cr b/src/spectator/mocks/null_stub.cr index b0cef54..df154b6 100644 --- a/src/spectator/mocks/null_stub.cr +++ b/src/spectator/mocks/null_stub.cr @@ -5,7 +5,7 @@ module Spectator # Stub that does nothing and returns nil. class NullStub < TypedStub(Nil) # Invokes the stubbed implementation. - def call(_call : MethodCall) : Nil + def call(call : MethodCall) : Nil end end end diff --git a/src/spectator/mocks/value_stub.cr b/src/spectator/mocks/value_stub.cr index 32b414f..70aae91 100644 --- a/src/spectator/mocks/value_stub.cr +++ b/src/spectator/mocks/value_stub.cr @@ -7,7 +7,7 @@ module Spectator # Stub that responds with a static value. class ValueStub(T) < TypedStub(T) # Invokes the stubbed implementation. - def call(_call : MethodCall) : T + def call(call : MethodCall) : T @value 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