-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error message for n.times syntax #4
Conversation
And add specs.
The specs are more important, so run them first. Runtime is pretty similar at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good improvement 👍
if expected.is_a?(Enumerator) && expected.inspect.match?(/:times>$/) | ||
expected = expected.size | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking today that we should create a new object:
@matcher = QueryMatcher.new(@queries)
@matcher.matches?(expected)
That matcher would implement the different cases of comparing to different types. It would be easier to test that class and by storing it in an ivar, we can re-use it to print the error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a good idea 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one 👍
And add specs.