Sha256: fb9b608cd15b6e37e400947de5f9c041484350381ae711e2c61e971bfb126818

Contents?: true

Size: 796 Bytes

Versions: 8

Compression:

Stored size: 796 Bytes

Contents

require 'spec_helper'

describe DateTime do
  let(:date_time) { parse_time("2010-01-01 00:00:00") }

  it "should allow advancing by calendar days" do
    expect(date_time.advance_considering_calendar(:calendar_days, 10))
      .to eq parse_time("2010-01-10 23:59:59")
  end

  it "should allow advancing by calendar months" do
    expect(date_time.advance_considering_calendar(:calendar_months, 10))
      .to eq parse_time("2010-10-31 23:59:59")
  end

  it "should allow advancing by calendar years" do
    expect(date_time.advance_considering_calendar(:calendar_years, 10))
      .to eq parse_time("2019-12-31 23:59:59")
  end

  def parse_time(time)
    # ActiveSupport 5.1+ returns end of day differently
    # Returns with usec at 999999 vs 0
    DateTime.parse(time).end_of_day
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
timely-0.5.0 spec/rails/date_time_spec.rb
timely-0.4.2 spec/rails/date_time_spec.rb
timely-0.4.1 spec/rails/date_time_spec.rb
timely-0.4.0 spec/rails/date_time_spec.rb
timely-0.3.4 spec/rails/date_time_spec.rb
timely-0.3.2 spec/rails/date_time_spec.rb
timely-0.3.1 spec/rails/date_time_spec.rb
timely-0.3.0 spec/rails/date_time_spec.rb