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

Version Path
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/rspec-core-2.8.0/lib/rspec/core/formatters/helpers.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/rspec-core-2.8.0/lib/rspec/core/formatters/helpers.rb
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/formatters/helpers.rb
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-core-2.8.0/lib/rspec/core/formatters/helpers.rb
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/formatters/helpers.rb
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-core-2.8.0/lib/rspec/core/formatters/helpers.rb
horseman-0.0.2 vendor/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/formatters/helpers.rb
rspec-core-2.8.0 lib/rspec/core/formatters/helpers.rb
nutshell-crm-0.0.6.alpha vendor/bundle/gems/rspec-core-2.7.1/lib/rspec/core/formatters/helpers.rb
rspec-core-2.8.0.rc2 lib/rspec/core/formatters/helpers.rb
nutshell-crm-0.0.5 vendor/bundle/gems/rspec-core-2.7.1/lib/rspec/core/formatters/helpers.rb
nutshell-crm-0.0.4 vendor/bundle/gems/rspec-core-2.7.1/lib/rspec/core/formatters/helpers.rb
nutshell-crm-0.0.3 vendor/bundle/gems/rspec-core-2.7.1/lib/rspec/core/formatters/helpers.rb
nutshell-crm-0.0.2 vendor/bundle/gems/rspec-core-2.7.1/lib/rspec/core/formatters/helpers.rb
nutshell-crm-0.0.1 vendor/bundle/gems/rspec-core-2.7.1/lib/rspec/core/formatters/helpers.rb
rspec-core-2.8.0.rc1 lib/rspec/core/formatters/helpers.rb
rspec-core-2.7.1 lib/rspec/core/formatters/helpers.rb
rspec-core-2.7.0 lib/rspec/core/formatters/helpers.rb
rspec-core-2.7.0.rc1 lib/rspec/core/formatters/helpers.rb
rspec-core-2.6.4 lib/rspec/core/formatters/helpers.rb