summaryrefslogtreecommitdiff
path: root/spec/ci/helpers/application_helper_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ci/helpers/application_helper_spec.rb')
-rw-r--r--spec/ci/helpers/application_helper_spec.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/ci/helpers/application_helper_spec.rb b/spec/ci/helpers/application_helper_spec.rb
new file mode 100644
index 00000000000..c2b1058a8fa
--- /dev/null
+++ b/spec/ci/helpers/application_helper_spec.rb
@@ -0,0 +1,37 @@
+require 'spec_helper'
+
+describe ApplicationHelper 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|
+ duration_in_words(Time.now + interval, Time.now).should == expectation
+ end
+ end
+
+ it "calculates interval from now if there is no finished_at" do
+ duration_in_words(nil, Time.now - 5).should == "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|
+ time_interval_in_words(interval).should == expectation
+ end
+ end
+ end
+end