Sha256: ae111093d17adf3987286047a43b6347b687aa266961b1eff76cece681355623

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

class TimeMockedWithTimecop
  def self.now_without_mock_time; end
end

class TimeMockedWithDelorean
  def self.now_without_delorean; end
end

class TimeMockedWithActiveSupport
  def self.__simple_stub__now; end
end

class UnmockedTime
  def self.now; end
end

class           ProgressBar
RSpec.describe  Time do
  it 'when Time is being mocked by Timecop retrieves the unmocked Timecop time' do
    expect(TimeMockedWithTimecop).to receive(:now_without_mock_time).once

    Time.new(TimeMockedWithTimecop).now
  end

  it 'when Time is being mocked by Delorean retrieves the unmocked Delorean time' do
    expect(TimeMockedWithDelorean).to receive(:now_without_delorean).once

    Time.new(TimeMockedWithDelorean).now
  end

  it 'when Time is being mocked by ActiveSupport retrieves the unmocked time' do
    expect(TimeMockedWithActiveSupport).to receive(:__simple_stub__now).once

    Time.new(TimeMockedWithActiveSupport).now
  end

  it 'when Time is not being mocked will return the actual time' do
    expect(UnmockedTime).to receive(:now).once

    Time.new(UnmockedTime).now
  end
end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/ruby-progressbar-1.8.1/spec/ruby-progressbar/time_spec.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/ruby-progressbar-1.8.1/spec/ruby-progressbar/time_spec.rb
progressbar-1.8.2 spec/ruby-progressbar/time_spec.rb
progressbar-1.8.1 spec/ruby-progressbar/time_spec.rb
ruby-progressbar-1.8.1 spec/ruby-progressbar/time_spec.rb
ruby-progressbar-1.8.0 spec/ruby-progressbar/time_spec.rb