Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Revisit equality of zero #1122

Open
sk- opened this issue Feb 18, 2025 · 0 comments
Open

Revisit equality of zero #1122

sk- opened this issue Feb 18, 2025 · 0 comments

Comments

@sk-
Copy link

sk- commented Feb 18, 2025

Pr #515 introduced a change to the equality comparison where two money instances of different currencies will be equal if their amount is zero.

This is problematic as it breaks expectations, for example if you are explicitly expecting to receive 0 USD, but the you received 0 EUR, the code will silently work if you are using built in equality. This applies to both expectations and matchers used in mocking.

This case was hard to debug in our application and we fix it with a custom especially matcher that does a strict equality check.

I’d even argue that the motivating issue in money-rails stems from the lax use of auto converting integers to money instances where the default was unexpected.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant