Sha256: 8cab816af29065a493e3af2bd677987327d9babb536d7ee47539beb065d67888

Contents?: true

Size: 872 Bytes

Versions: 3

Compression:

Stored size: 872 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

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

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

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

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

        it 'returns the days between' do
          expect(subject.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(subject.days_between(time)).to eq(365)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
darthjee-core_ext-1.7.3 spec/integration/yard/date/days_between_spec.rb
darthjee-core_ext-1.7.2 spec/integration/yard/date/days_between_spec.rb
darthjee-core_ext-1.7.1 spec/integration/yard/date/days_between_spec.rb