Sha256: c49a0bb87955c719bb58ddaa9e793b463c0c941e638e19d784da58786a0d624d

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'
require 'gb_work_day/interval'
require 'active_support/time'


describe GBWorkDay::Interval do
  it 'properly calculate work days for interval' do
    week = GBWorkDay::WorkWeek.new(5)
    monday = Date.today.beginning_of_week
    expect(GBWorkDay::Interval.new(monday - 1.day, monday, week: week).duration.work_days).to eq 0
    expect(GBWorkDay::Interval.new(monday - 2.day, monday, week: week).duration.work_days).to eq 0
    expect(GBWorkDay::Interval.new(monday + 1.day, monday, week: week).duration.work_days).to eq -1
    expect(GBWorkDay::Interval.new(monday, monday + 1.day, week: week).duration.work_days).to eq 1
    expect(GBWorkDay::Interval.new(monday, monday + 5.day, week: week).duration.work_days).to eq 5
    expect(GBWorkDay::Interval.new(monday, monday + 7.day, week: week).duration.work_days).to eq 5
    expect(GBWorkDay::Interval.new(monday, monday + 12.day, week: week).duration.work_days).to eq 10
    expect(GBWorkDay::Interval.new(monday, monday + 14.day, week: week).duration.work_days).to eq 10
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gb_work_day-0.0.6 spec/interval_spec.rb
gb_work_day-0.0.4 spec/interval_spec.rb
gb_work_day-0.0.3 spec/interval_spec.rb
gb_work_day-0.0.2 spec/interval_spec.rb
gb_work_day-0.0.1 spec/interval_spec.rb