Closed UrsaDK closed 3 years ago
It appears this affected the respond_to
, have_attributes
, be_xxx
, and have_xxx
matchers. Those have all been fixed. The issue was that description
was the name of another argument in the parameter list, so when it got splatted, it looked like this:
FailedMatchData.new(description, "foo", description: true)
The splat operation has been removed. This will be in 0.9.25, pushing out now. You happened to catch me while I was working on Spectator. :smile:
Also, I don't know if this is just from making a code snippet, but the code:
expect(A).to respond_to(:description)
will fail the test case because A#description
is an instance method. So technically A
won't respond to description
, but anything that includes it will. To make the code pass the test, A
should be:
module A
extend self # <--- Add this
# ...
end
Thank you so much for fixing this so quickly!
And yes, you're absolutely right about the code snippet. I made it on the fly, based on my existing code and simply forgot to include extend self
. My priority was to highlight the issue. Having a passing test would have been nice, but I'm glad that a failing one demonstrated the issue just as well. :)
A good example is worth 1000 words, so here is how to recreate the problem:
main.cr:
main_spec.cr:
Running
crystal spec
with spectator 0.9.24 throws the following error:Based on a very brief look, I think the problem is in failed_match_data.cr#L23:
From what I can gather, when we test a method that happens to be called
description
then the key supplied as part of**values
overrides identically named method parameter. Unfortunately, I'm not familiar enough with the codebase to propose a solution or help with a PR.