Sha256: 01edb2495e2698a7a0f33c993bc6bad22fc982747618a615316dcdfd880c39b3

Contents?: true

Size: 976 Bytes

Versions: 5

Compression:

Stored size: 976 Bytes

Contents

# typed: false
# frozen_string_literal: true

require './spec/spec_setup'
require 'frontman/toolbox/timer'

describe Frontman::Toolbox::Timer do
  it 'should create and start a timer' do
    timer = Frontman::Toolbox::Timer.start
    expect(timer).to be_a Frontman::Toolbox::Timer
    expect(timer.started_at).to_not eq nil
    expect(timer.ended_at).to eq nil
  end

  it 'should set the stop time correctly' do
    timer = Frontman::Toolbox::Timer.start
    timer.stop
    expect(timer.ended_at).to_not eq nil
  end

  it 'should calculate the correct difference' do
    timer = Frontman::Toolbox::Timer.new
    start_time = timer.begin
    end_time = timer.stop
    expect(timer.diff).to eq(end_time - start_time)
  end

  it 'should show the correct output' do
    timer = Frontman::Toolbox::Timer.new
    start_time = timer.begin
    end_time = timer.stop
    expect(timer.output).to eq "Elapsed time: ~#{((end_time - start_time) * 1000).ceil} milliseconds.\n"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
frontman-ssg-0.1.1 spec/frontman/toolbox/timer_spec.rb
frontman-ssg-0.1.0 spec/frontman/toolbox/timer_spec.rb
frontman-ssg-0.0.4 spec/frontman/toolbox/timer_spec.rb
frontman-ssg-0.0.3 spec/frontman/toolbox/timer_spec.rb
frontman-ssg-0.0.2 spec/frontman/toolbox/timer_spec.rb