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
Comparison of ActiveSupport::Duration objects raises unexpected error #37012
Comments
Am willing to submit a corrective patch but am wondering if this behaviour is by design before I do. If string input is unsupported by |
Addresses rails/rails github issue rails#37012 by ensuring the value in the objects instantiated by .build is always an integer or float
Added an additional fail-case: |
Summary
ActiveSupport::Duration
objects created viaActiveSupport::Duration.build
exhibit unexpected behaviour when instantiated with a string value.Steps to reproduce
Rails console exemplar
Minimal test cases
Expected behavior
ActiveSupport::Duration
objects with identical.parts
should be comparable and equivalent, regardless of how they were built:a_duration_from_string < a_duration_from_integer
should returnfalse
a_duration_from_string == a_duration_from_integer
should returntrue
large_duration_from_string > small_duration_from_string
should returntrue
Actual behavior
a_duration_from_string < a_duration_from_integer
raises anArgumentError
a_duration_from_string == a_duration_from_integer
returnsfalse
large_duration_from_string > small_duration_from_string
returnsfalse
System configuration
Rails version: 5.2.2.1
Ruby version: 2.6.3
The text was updated successfully, but these errors were encountered: