Sha256: d0be04bd8e1130af920904f128035dd37c59b4e4205fd23bf9cc7fbd8d3591ce

Contents?: true

Size: 1.28 KB

Versions: 172

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 time execution for tests: 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

172 entries across 172 versions & 1 rubygems

Version Path
knapsack_pro-6.0.4 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-6.0.3 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-6.0.2 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-6.0.1 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-6.0.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.7.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.6.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.5.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.4.1 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.4.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.3.5 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.3.4 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.3.3 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.3.2 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.3.1 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.3.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.2.1 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.2.0 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.1.2 spec/knapsack_pro/presenter_spec.rb
knapsack_pro-5.1.1 spec/knapsack_pro/presenter_spec.rb