Sha256: 48717d8a8e8b715e527ecd2f55d72178e9bcb883ca7dac7ca91ac855e51e8577
Contents?: true
Size: 535 Bytes
Versions: 27
Compression:
Stored size: 535 Bytes
Contents
module RSpec module Core module Formatters module Helpers SUB_SECOND_PRECISION = 5 DEFAULT_PRECISION = 2 def format_seconds(float) precision ||= (float < 1) ? SUB_SECOND_PRECISION : DEFAULT_PRECISION formatted = sprintf("%.#{precision}f", float) strip_trailing_zeroes(formatted) end def strip_trailing_zeroes(string) stripped = string.sub(/[^1-9]+$/, '') stripped.empty? ? "0" : stripped end end end end end
Version data entries
27 entries across 25 versions & 4 rubygems