Skip to content
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

Merged
merged 4 commits into from
Apr 15, 2024
Merged

Improve error message for n.times syntax #4

merged 4 commits into from
Apr 15, 2024

Conversation

mkllnk
Copy link
Member

@mkllnk mkllnk commented Apr 11, 2024

@mkllnk mkllnk self-assigned this Apr 11, 2024
The specs are more important, so run them first. Runtime is pretty
similar at the moment.
@mkllnk mkllnk marked this pull request as ready for review April 11, 2024 05:51
Copy link
Member

@dacook dacook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvement 👍

Comment on lines +34 to +37
if expected.is_a?(Enumerator) && expected.inspect.match?(/:times>$/)
expected = expected.size
end

Copy link
Member Author

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.

Copy link
Member

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 👍

Copy link

@rioug rioug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one 👍

@mkllnk mkllnk merged commit f65c9f3 into main Apr 15, 2024
2 checks passed
@mkllnk mkllnk deleted the error-messages branch April 15, 2024 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants