Sha256: 7e53d789ea8c4fcf14ddac46e77ac6102531dd0166f0ba13693d842a9693cf4e

Contents?: true

Size: 1.28 KB

Versions: 16

Compression:

Stored size: 1.28 KB

Contents

describe KnapsackPro::Presenter do
  describe '.global_time' do
    let(:tracker) { instance_double(KnapsackPro::Tracker, global_time: 60*62+3) }

    subject { described_class.global_time }

    before do
      expect(KnapsackPro).to receive(:tracker).and_return(tracker)
    end

    it { should eql "Global test execution duration: 01h 02m 03s" }
  end

  describe '.pretty_seconds' do
    subject { described_class.pretty_seconds(seconds) }

    context 'when less then one second' do
      let(:seconds) { 0.987 }
      it { should eql '0.987s' }
    end

    context 'when one second' do
      let(:seconds) { 1 }
      it { should eql '01s' }
    end

    context 'when only seconds' do
      let(:seconds) { 5 }
      it { should eql '05s' }
    end

    context 'when only minutes' do
      let(:seconds) { 120 }
      it { should eql '02m' }
    end

    context 'when only hours' do
      let(:seconds) { 60*60*3 }
      it { should eql '03h' }
    end

    context 'when minutes and seconds' do
      let(:seconds) { 180+9 }
      it { should eql '03m 09s' }
    end

    context 'when all' do
      let(:seconds) { 60*60*4+120+7 }
      it { should eql '04h 02m 07s' }
    end

    context 'when negative seconds' do
      let(:seconds) { -67 }
      it { should eql '-01m 07s' }
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
knapsack_pro-7.13.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.12.1 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.12.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.11.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.10.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.9.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.8.2 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.8.1 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.8.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.7.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.6.2 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.6.1 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.6.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.1.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.0.1 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-7.0.0 spec/knapsack_pro/presenter_spec.rb