From 3d9a7cdb4be6d6d059dfd7ccc8fa2e4bd3ab12e3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 29 Sep 2015 16:26:40 +0200 Subject: Refactor CI helpers Signed-off-by: Dmitriy Zaporozhets --- spec/helpers/ci/application_helper_spec.rb | 37 ------------------------------ spec/helpers/ci/runners_helper_spec.rb | 18 --------------- spec/helpers/runners_helper_spec.rb | 18 +++++++++++++++ spec/helpers/time_helper_spec.rb | 37 ++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 55 deletions(-) delete mode 100644 spec/helpers/ci/application_helper_spec.rb delete mode 100644 spec/helpers/ci/runners_helper_spec.rb create mode 100644 spec/helpers/runners_helper_spec.rb create mode 100644 spec/helpers/time_helper_spec.rb (limited to 'spec/helpers') diff --git a/spec/helpers/ci/application_helper_spec.rb b/spec/helpers/ci/application_helper_spec.rb deleted file mode 100644 index 6a216715b7f..00000000000 --- a/spec/helpers/ci/application_helper_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper' - -describe Ci::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| - 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 diff --git a/spec/helpers/ci/runners_helper_spec.rb b/spec/helpers/ci/runners_helper_spec.rb deleted file mode 100644 index 6d0e2d3d1e1..00000000000 --- a/spec/helpers/ci/runners_helper_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -describe Ci::RunnersHelper do - it "returns - not contacted yet" do - runner = FactoryGirl.build :ci_runner - expect(runner_status_icon(runner)).to include("not connected yet") - end - - it "returns offline text" do - runner = FactoryGirl.build(:ci_runner, contacted_at: 1.day.ago, active: true) - expect(runner_status_icon(runner)).to include("Runner is offline") - end - - it "returns online text" do - runner = FactoryGirl.build(:ci_runner, contacted_at: 1.hour.ago, active: true) - expect(runner_status_icon(runner)).to include("Runner is online") - end -end diff --git a/spec/helpers/runners_helper_spec.rb b/spec/helpers/runners_helper_spec.rb new file mode 100644 index 00000000000..b3d635a1932 --- /dev/null +++ b/spec/helpers/runners_helper_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe RunnersHelper do + it "returns - not contacted yet" do + runner = FactoryGirl.build :ci_runner + expect(runner_status_icon(runner)).to include("not connected yet") + end + + it "returns offline text" do + runner = FactoryGirl.build(:ci_runner, contacted_at: 1.day.ago, active: true) + expect(runner_status_icon(runner)).to include("Runner is offline") + end + + it "returns online text" do + runner = FactoryGirl.build(:ci_runner, contacted_at: 1.hour.ago, active: true) + expect(runner_status_icon(runner)).to include("Runner is online") + end +end 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 -- cgit v1.2.1