Sha256: 4595f244f8e919b8700b01f34481a09ad48d9fcca2e40259e4eb18747fba3cbf

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe Integer do
  describe '#months' do
    it 'returns 0.month as seconds' do
      seconds = 0
      expect(0.month).to  eq(seconds)
      expect(0.months).to eq(seconds)
    end

    it 'returns 1 month as seconds' do
      seconds = 1 * 30 * 24 * 60 * 60
      expect(1.month).to  eq(seconds)
      expect(1.months).to eq(seconds)
    end

    it 'returns 3 months as seconds' do
      seconds = 3 * 30 * 24 * 60 * 60
      expect(3.month).to  eq(seconds)
      expect(3.months).to eq(seconds)
    end

    it 'returns -2 months as seconds' do
      seconds = -2 * 30 * 24 * 60 * 60
      expect(-2.month).to  eq(seconds)
      expect(-2.months).to eq(seconds)
    end
  end

  describe '#years' do
    it 'returns 0 years as seconds' do
      seconds = 0
      expect(0.year).to  eq(seconds)
      expect(0.years).to eq(seconds)
    end

    it 'returns 1 month as seconds' do
      seconds = 1 * 365.25 * 24 * 60 * 60
      expect(1.year).to  eq(seconds)
      expect(1.years).to eq(seconds)
    end

    it 'returns 3 years as seconds' do
      seconds = 3 * 365.25 * 24 * 60 * 60
      expect(3.year).to  eq(seconds)
      expect(3.years).to eq(seconds)
    end

    it 'returns -2 years as seconds' do
      seconds = -2 * 365.25 * 24 * 60 * 60
      expect(-2.year).to  eq(seconds)
      expect(-2.years).to eq(seconds)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
timeloop-2.0.0 spec/unit/core_ext/integer_spec.rb
timeloop-1.0.3 spec/unit/core_ext/integer_spec.rb
timeloop-1.0.0 spec/unit/core_ext/integer_spec.rb