Sha256: 5a26118949b5b395539e233e646462e82b1751659f8402d7f8016f72c294e1fd

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

require 'rspectacular'

class TimeMockedWithTimecop
  def self.now; end
  def self.now_without_mock_time; end
end

class TimeMockedWithDelorean
  def self.now; end
  def self.now_without_delorean; end
end

class UnmockedTime
  def self.now; end
end

describe ProgressBar::Time do
  describe '#now' do
    context 'when Time is being mocked by Timecop' do
      subject { ProgressBar::Time.now ::TimeMockedWithTimecop }

      it 'retrieves the unmocked Timecop time' do
        allow(::TimeMockedWithTimecop).to receive(:now_without_mock_time).once

        subject
      end
    end

    context 'when Time is being mocked by Delorean' do
      subject { ProgressBar::Time.now ::TimeMockedWithDelorean }

      it 'retrieves the unmocked Delorean time' do
        allow(::TimeMockedWithDelorean).to receive(:now_without_delorean).once

        subject
      end
    end

    context 'when Time is not being mocked' do
      subject { ProgressBar::Time.now ::UnmockedTime }

      it 'will return the actual time' do
        allow(::UnmockedTime).to receive(:now).once

        subject
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/ruby-progressbar-1.5.1/spec/lib/ruby-progressbar/time_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/ruby-progressbar-1.5.1/spec/lib/ruby-progressbar/time_spec.rb
ruby-progressbar-1.6.0 spec/lib/ruby-progressbar/time_spec.rb
ruby-progressbar-1.5.1 spec/lib/ruby-progressbar/time_spec.rb
ruby-progressbar-1.5.0 spec/lib/ruby-progressbar/time_spec.rb