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.10.0 spec/duration_spec.rb
woople-theme-0.9.0 spec/duration_spec.rb
woople-theme-0.8.19 spec/duration_spec.rb
woople-theme-0.8.18 spec/duration_spec.rb
woople-theme-0.8.17 spec/duration_spec.rb
woople-theme-0.8.16 spec/duration_spec.rb
woople-theme-0.8.15 spec/duration_spec.rb
woople-theme-0.8.14 spec/duration_spec.rb
woople-theme-0.8.13 spec/duration_spec.rb
woople-theme-0.8.12 spec/duration_spec.rb
woople-theme-0.8.11 spec/duration_spec.rb
woople-theme-0.8.10 spec/duration_spec.rb
woople-theme-0.8.9 spec/duration_spec.rb
woople-theme-0.8.8 spec/duration_spec.rb
woople-theme-0.8.7 spec/duration_spec.rb
woople-theme-0.8.6 spec/duration_spec.rb
woople-theme-0.8.5 spec/duration_spec.rb
woople-theme-0.8.4 spec/duration_spec.rb
woople-theme-0.8.3 spec/duration_spec.rb
woople-theme-0.8.2 spec/duration_spec.rb