BigW Consortium Gitlab

time_helper_spec.rb 895 Bytes
Newer Older
1 2
require 'spec_helper'

3
describe TimeHelper do
4
  describe "#time_interval_in_words" do
5 6 7
    it "returns minutes and seconds" do
      intervals_in_words = {
        100 => "1 minute 40 seconds",
8
        100.32 => "1 minute 40 seconds",
9 10 11 12 13 14
        121 => "2 minutes 1 second",
        3721 => "62 minutes 1 second",
        0 => "0 seconds"
      }

      intervals_in_words.each do |interval, expectation|
15
        expect(time_interval_in_words(interval)).to eq(expectation)
16 17 18 19
      end
    end
  end

20
  describe "#duration_in_numbers" do
21
    it "returns minutes and seconds" do
22 23 24 25 26 27
      durations_and_expectations = {
        100 => "01:40",
        121 => "02:01",
        3721 => "01:02:01",
        0 => "00:00",
        42 => "00:42"
28 29
      }

30 31
      durations_and_expectations.each do |duration, expectation|
        expect(duration_in_numbers(duration)).to eq(expectation)
32 33 34 35
      end
    end
  end
end