Sha256: ac84b812f5d65ae4b749292abbcb148043e6d18f6bd5f650395fbe4635b6ada8

Contents?: true

Size: 1.05 KB

Versions: 36

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'
require 'duration'

describe Duration do

  describe "format_time" do
    it 'returns the correctly formatted string' do
      Duration.format_time(-1).should == '0:00'
      Duration.format_time(0).should  == '0:00'
      Duration.format_time( time_in_ms(0,0,1)  ).should == "0:01"
      Duration.format_time( time_in_ms(0,1,0)  ).should == "1:00"
      Duration.format_time( time_in_ms(0,1,1)  ).should == "1:01"
      Duration.format_time( time_in_ms(1,0,0)  ).should == "1:00:00"
      Duration.format_time( time_in_ms(1,0,1)  ).should == "1:00:01"
      Duration.format_time( time_in_ms(1,1,0)  ).should == "1:01:00"
      Duration.format_time( time_in_ms(1,30,0) ).should == "1:30:00"
      Duration.format_time( time_in_ms(999,59,59) ).should == "999:59:59"
    end
  end
  def time_in_ms(hour, minute, second)
      second_multiplier = 1000
      minute_multiplier = second_multiplier * 60
      hour_multiplier = minute_multiplier * 60

      time = hour * hour_multiplier + minute * minute_multiplier + second * second_multiplier
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
woople-theme-0.8.1 spec/duration_spec.rb
woople-theme-0.8.0 spec/duration_spec.rb
woople-theme-0.6.27 spec/duration_spec.rb
woople-theme-0.6.26 spec/duration_spec.rb
woople-theme-0.6.25 spec/duration_spec.rb
woople-theme-0.6.24 spec/duration_spec.rb
woople-theme-0.6.23 spec/duration_spec.rb
woople-theme-0.6.22 spec/duration_spec.rb
woople-theme-0.6.21 spec/duration_spec.rb
woople-theme-0.6.20 spec/duration_spec.rb
woople-theme-0.6.19 spec/duration_spec.rb
woople-theme-0.6.18 spec/duration_spec.rb
woople-theme-0.6.17 spec/duration_spec.rb
woople-theme-0.6.14 spec/duration_spec.rb
woople-theme-0.6.13 spec/duration_spec.rb
woople-theme-0.6.12 spec/duration_spec.rb