Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-29 17:26:40 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-29 17:26:40 +0300
commit3d9a7cdb4be6d6d059dfd7ccc8fa2e4bd3ab12e3 (patch)
treefbc4fb4a8ae361436e92c794c01ebab2c83c4e18 /spec/helpers/time_helper_spec.rb
parent87240e989ba913bad787d8bc81da1a9b87f1da53 (diff)
Refactor CI helpers
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/helpers/time_helper_spec.rb')
-rw-r--r--spec/helpers/time_helper_spec.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/helpers/time_helper_spec.rb b/spec/helpers/time_helper_spec.rb
new file mode 100644
index 00000000000..3f62527c5bb
--- /dev/null
+++ b/spec/helpers/time_helper_spec.rb
@@ -0,0 +1,37 @@
+require 'spec_helper'
+
+describe TimeHelper do
+ describe "#duration_in_words" do
+ it "returns minutes and seconds" do
+ intervals_in_words = {
+ 100 => "1 minute 40 seconds",
+ 121 => "2 minutes 1 second",
+ 3721 => "62 minutes 1 second",
+ 0 => "0 seconds"
+ }
+
+ intervals_in_words.each do |interval, expectation|
+ expect(duration_in_words(Time.now + interval, Time.now)).to eq(expectation)
+ end
+ end
+
+ it "calculates interval from now if there is no finished_at" do
+ expect(duration_in_words(nil, Time.now - 5)).to eq("5 seconds")
+ end
+ end
+
+ describe "#time_interval_in_words" do
+ it "returns minutes and seconds" do
+ intervals_in_words = {
+ 100 => "1 minute 40 seconds",
+ 121 => "2 minutes 1 second",
+ 3721 => "62 minutes 1 second",
+ 0 => "0 seconds"
+ }
+
+ intervals_in_words.each do |interval, expectation|
+ expect(time_interval_in_words(interval)).to eq(expectation)
+ end
+ end
+ end
+end