debian-mirror-gitlab/spec/helpers/time_helper_spec.rb

39 lines
1.1 KiB
Ruby
Raw Normal View History

2015-09-25 12:07:36 +05:30
require 'spec_helper'
2015-10-24 18:46:33 +05:30
describe TimeHelper do
2016-08-24 12:49:21 +05:30
describe "#time_interval_in_words" do
2015-09-25 12:07:36 +05:30
it "returns minutes and seconds" do
intervals_in_words = {
2018-11-18 11:00:15 +05:30
60 => "1 minute",
100 => "1 minute and 40 seconds",
100.32 => "1 minute and 40 seconds",
120 => "2 minutes",
121 => "2 minutes and 1 second",
3721 => "62 minutes and 1 second",
2015-09-25 12:07:36 +05:30
0 => "0 seconds"
}
intervals_in_words.each do |interval, expectation|
2016-08-24 12:49:21 +05:30
expect(time_interval_in_words(interval)).to eq(expectation)
2015-09-25 12:07:36 +05:30
end
end
end
2016-08-24 12:49:21 +05:30
describe "#duration_in_numbers" do
2018-12-05 23:21:45 +05:30
using RSpec::Parameterized::TableSyntax
2018-12-13 13:39:08 +05:30
where(:duration, :formatted_string) do
0 | "00:00"
1.second | "00:01"
42.seconds | "00:42"
2.minutes + 1.second | "02:01"
3.hours + 2.minutes + 1.second | "03:02:01"
30.hours | "30:00:00"
2018-12-05 23:21:45 +05:30
end
2018-12-13 13:39:08 +05:30
with_them do
it { expect(duration_in_numbers(duration)).to eq formatted_string }
2015-09-25 12:07:36 +05:30
end
end
end