Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Formatters helper format_duration incorrectly formats time when using mathn #1086

Closed
greggroth opened this issue Sep 27, 2013 · 1 comment
Closed

Comments

@greggroth
Copy link

If mathn is required, then format_duration will report the minutes as a fraction rather than casting to an integer (consequently, the seconds calculation is also wrong). For example:

       expected: "1 minute 10.14 seconds"
            got: "7/6 minutes 0.14 seconds"

The challenge is testing this with and without mathn loaded. I think it's a bad idea to just require it in the formatters since that will could cause failures in test suites that aren't expecting to have mathn loaded. However, it would be better if the times could be well-formatted for applications that do use mathn. The solution is simple, but I'm having a difficult time writing a test for this that doesn't leave mathn hanging around to affect other tests. Are there any ideas on how a test can be written for this?

iamvery added a commit to iamvery/rspec-core that referenced this issue Sep 27, 2013
* As @greggroth pointed out in rspec#1086, the formatter
  does not work as expected when the mathn lib is loaded. This lib adds
  the Rational type which is formatted as "n/n" when stringified rather
  than the float form. By explicitly converting the arithmetic to the
  types we wish to stringify, this display is corrected.

[rspec#1086]
@myronmarston
Copy link
Member

Fixed by #1087.

myronmarston pushed a commit that referenced this issue Sep 28, 2013
* As @greggroth pointed out in #1086, the formatter
  does not work as expected when the mathn lib is loaded. This lib adds
  the Rational type which is formatted as "n/n" when stringified rather
  than the float form. By explicitly converting the arithmetic to the
  types we wish to stringify, this display is corrected.
* This contains all commits of PR #1087, squashed
  together for easy back-porting to 2-14-maintenance
  and 2-99-maintenance.
myronmarston pushed a commit that referenced this issue Sep 28, 2013
* As @greggroth pointed out in #1086, the formatter
  does not work as expected when the mathn lib is loaded. This lib adds
  the Rational type which is formatted as "n/n" when stringified rather
  than the float form. By explicitly converting the arithmetic to the
  types we wish to stringify, this display is corrected.
* This contains all commits of PR #1087, squashed
  together for easy back-porting to 2-14-maintenance
  and 2-99-maintenance.
yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this issue Oct 6, 2021
* As @greggroth pointed out in rspec/rspec-core#1086, the formatter
  does not work as expected when the mathn lib is loaded. This lib adds
  the Rational type which is formatted as "n/n" when stringified rather
  than the float form. By explicitly converting the arithmetic to the
  types we wish to stringify, this display is corrected.
* This contains all commits of PR rspec/rspec-core#1087, squashed
  together for easy back-porting to 2-14-maintenance
  and 2-99-maintenance.

---
This commit was imported from rspec/rspec-core@0f99d62.
yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this issue Oct 6, 2021
* As @greggroth pointed out in rspec/rspec-core#1086, the formatter
  does not work as expected when the mathn lib is loaded. This lib adds
  the Rational type which is formatted as "n/n" when stringified rather
  than the float form. By explicitly converting the arithmetic to the
  types we wish to stringify, this display is corrected.
* This contains all commits of PR rspec/rspec-core#1087, squashed
  together for easy back-porting to 2-14-maintenance
  and 2-99-maintenance.

---
This commit was imported from rspec/rspec-core@490ec33.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants