Sha256: 2a09a6703fc2ead5a317ae457ef0d94b9a2d806f9a1684520f59043a493a5d85

Contents?: true

Size: 1.15 KB

Versions: 36

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'
require 'stringio'

describe RSpec::Core::Formatters::Helpers do
  let(:helper) { helper = Object.new.extend(RSpec::Core::Formatters::Helpers) }

  describe "format seconds" do
    context "sub second times" do
      it "returns 5 digits of precision" do
        helper.format_seconds(0.000006).should == "0.00001"
      end

      it "strips off trailing zeroes beyond sub-second precision" do
        helper.format_seconds(0.020000).should == "0.02"
      end

      context "0" do
        it "strips off trailing zeroes" do
          helper.format_seconds(0.00000000001).should == "0"
        end
      end

      context "> 1" do
        it "strips off trailing zeroes" do
          helper.format_seconds(1.00000000001).should == "1"
        end
      end
    end

    context "second and greater times" do

      it "returns 2 digits of precision" do
        helper.format_seconds(50.330340).should == "50.33"
      end

      it "returns human friendly elasped time" do
        helper.format_seconds(50.1).should == "50.1"
        helper.format_seconds(5).should == "5"
        helper.format_seconds(5.0).should == "5"
      end

    end
  end


end

Version data entries

36 entries across 36 versions & 4 rubygems

Version Path
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rspec-core-2.5.1/spec/rspec/core/formatters/helpers_spec.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rspec-core-2.5.1/spec/rspec/core/formatters/helpers_spec.rb
rspec-core-2.5.2 spec/rspec/core/formatters/helpers_spec.rb
rspec-core-2.5.1 spec/rspec/core/formatters/helpers_spec.rb
rspec-core-2.5.0 spec/rspec/core/formatters/helpers_spec.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rspec-core-2.1.0/spec/rspec/core/formatters/helpers_spec.rb
rspec-core-2.4.0 spec/rspec/core/formatters/helpers_spec.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/rspec-core-2.1.0/spec/rspec/core/formatters/helpers_spec.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/rspec-core-2.1.0/spec/rspec/core/formatters/helpers_spec.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/rspec-core-2.1.0/spec/rspec/core/formatters/helpers_spec.rb
rspec-core-2.3.1 spec/rspec/core/formatters/helpers_spec.rb
rspec-core-2.3.0 spec/rspec/core/formatters/helpers_spec.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/rspec-core-2.1.0/spec/rspec/core/formatters/helpers_spec.rb
rspec-core-2.2.1 spec/rspec/core/formatters/helpers_spec.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/rspec-core-2.1.0/spec/rspec/core/formatters/helpers_spec.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/rspec-core-2.1.0/spec/rspec/core/formatters/helpers_spec.rb
rspec-core-2.2.0 spec/rspec/core/formatters/helpers_spec.rb
rspec-core-2.1.0 spec/rspec/core/formatters/helpers_spec.rb
rspec-core-2.0.1 spec/rspec/core/formatters/helpers_spec.rb
gemrage-1.0.0 vendor/ruby/1.8/gems/rspec-core-2.0.0/spec/rspec/core/formatters/helpers_spec.rb