2015-08-26 01:42:46 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-09-29 14:26:40 +00:00
|
|
|
describe TimeHelper do
|
2016-07-18 14:44:10 +00:00
|
|
|
describe "#time_interval_in_words" do
|
2015-08-26 01:42:46 +00:00
|
|
|
it "returns minutes and seconds" do
|
|
|
|
intervals_in_words = {
|
|
|
|
100 => "1 minute 40 seconds",
|
2016-07-21 10:18:34 +00:00
|
|
|
100.32 => "1 minute 40 seconds",
|
2015-08-26 01:42:46 +00:00
|
|
|
121 => "2 minutes 1 second",
|
|
|
|
3721 => "62 minutes 1 second",
|
|
|
|
0 => "0 seconds"
|
|
|
|
}
|
|
|
|
|
|
|
|
intervals_in_words.each do |interval, expectation|
|
2016-07-18 14:44:10 +00:00
|
|
|
expect(time_interval_in_words(interval)).to eq(expectation)
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-18 14:44:10 +00:00
|
|
|
describe "#duration_in_numbers" do
|
2015-08-26 01:42:46 +00:00
|
|
|
it "returns minutes and seconds" do
|
2016-08-10 14:45:30 +00:00
|
|
|
durations_and_expectations = {
|
|
|
|
100 => "01:40",
|
|
|
|
121 => "02:01",
|
|
|
|
3721 => "01:02:01",
|
|
|
|
0 => "00:00",
|
|
|
|
42 => "00:42"
|
2015-08-26 01:42:46 +00:00
|
|
|
}
|
|
|
|
|
2016-08-10 14:45:30 +00:00
|
|
|
durations_and_expectations.each do |duration, expectation|
|
|
|
|
expect(duration_in_numbers(duration)).to eq(expectation)
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|