Sha256: 2e546a53ffa9505535f07ff8f4fc889ca1172aa68d5ea035fdf9d8b03219a99c

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Date do
  describe 'yard' do
    describe '#days_between' do
      subject(:date) { described_class.new(2018, 11, 21) }

      context 'when checking against another date' do
        let(:other_date) { described_class.new(2019, 11, 21) }

        it 'returns the days between' do
          expect(date.days_between(other_date)).to eq(365)
        end
      end

      context 'when cheking agains a 4 years apart date' do
        let(:other_date) { described_class.new(2014, 11, 21) }

        it 'returns the days between' do
          expect(date.days_between(other_date)).to eq(1461)
        end
      end

      context 'when checking against time' do
        let(:time) { Time.new(2017, 11, 21, 12, 0, 0) }

        it 'ignores the hours' do
          expect(date.days_between(time)).to eq(365)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
darthjee-core_ext-2.0.0 spec/integration/yard/darthjee/core_ext/date/days_between_spec.rb
darthjee-core_ext-1.7.4 spec/integration/yard/darthjee/core_ext/date/days_between_spec.rb