Sha256: cbb2dc323bf8cd312c17d8177722224c30ee504cec76e4c221358aa8ce2eccfa

Contents?: true

Size: 1.19 KB

Versions: 14

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

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
        ::TimeMockedWithTimecop.should_receive(:now_without_mock_time).once
        ::TimeMockedWithTimecop.should_not_receive(:now)

        subject
      end
    end

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

      it 'retrieves the unmocked Delorean time' do
        ::TimeMockedWithDelorean.should_receive(:now_without_delorean).once
        ::TimeMockedWithDelorean.should_not_receive(:now)

        subject
      end
    end

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

      it 'will return the actual time' do
        ::UnmockedTime.should_receive(:now).once

        subject
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
ruby-progressbar-1.4.2 spec/lib/ruby-progressbar/time_spec.rb
ruby-progressbar-1.4.1 spec/lib/ruby-progressbar/time_spec.rb
ruby-progressbar-1.4.0 spec/lib/ruby-progressbar/time_spec.rb
ruby-progressbar-1.3.2 spec/lib/ruby-progressbar/time_spec.rb
ruby-progressbar-1.3.1 spec/lib/ruby-progressbar/time_spec.rb
ruby-progressbar-1.3.0 spec/lib/ruby-progressbar/time_spec.rb
ruby-progressbar-1.2.0 spec/lib/ruby-progressbar/time_spec.rb
ruby-progressbar-1.1.1 spec/progress_bar/time_spec.rb
ruby-progressbar-1.1.0 spec/progress_bar/time_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/ruby-progressbar-1.0.2/spec/progress_bar/time_spec.rb
ruby-progressbar-1.0.2 spec/progress_bar/time_spec.rb
ruby-progressbar-1.0.1 spec/progress_bar/time_spec.rb
ruby-progressbar-1.0.0 spec/progress_bar/time_spec.rb
ruby-progressbar-1.0.0rc1 spec/progress_bar/time_spec.rb