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

stop 70 being displayed as 1 minute 1 second #1984

Merged
merged 3 commits into from
Jun 8, 2015

Conversation

yule
Copy link
Contributor

@yule yule commented Jun 5, 2015

70 seconds was having trailing 0's stripped so shown as 1 minute, 1 second. Changed the helper regex, based on this SO answer: http://stackoverflow.com/a/4913031/671422

@yule
Copy link
Contributor Author

yule commented Jun 8, 2015

Not sure why ci is failing, the change is fairly minor and the tests for the change and associated functionality are all fine

@JonRowe
Copy link
Member

JonRowe commented Jun 8, 2015

If you read the build failure, it's because you have trailing whitespace on lines 48 and 94 of the spec file.

@@ -70,8 +70,7 @@ def self.format_seconds(float, precision=nil)
# @param string [String] string with trailing zeros
# @return [String] string with trailing zeros removed
def self.strip_trailing_zeroes(string)
stripped = string.sub(/[^1-9]+$/, '')
stripped.empty? ? "0" : stripped
string.sub(/(?:(\..*[^0])0+|\.0+)$/, '\1')
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a rubular explanation here saying what this is doing e.g. http://rubular.com/r/ujWack5Utu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem, added link to Rubular, with few more specific examples. Basically looks for a decimal point followed by any number of non-zeros, then a zero (or more). Or just a decimal point and zeros. Then replaces this with the first match (i.e. the non-zeros)

myronmarston added a commit that referenced this pull request Jun 8, 2015
stop 70 being displayed as 1 minute 1 second
@myronmarston myronmarston merged commit 7b9d43e into rspec:master Jun 8, 2015
myronmarston added a commit that referenced this pull request Jun 8, 2015
MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
stop 70 being displayed as 1 minute 1 second
MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants