Sha256: 756895573d2c39f3a100991920bbf963c0417a36b1a5738b00a0fc881eef4f70

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

require_relative 'support/spec_helper'
require 'time_distribution/time'
require 'chronic'

include TimeDistribution
using TimeRefinement

def hours_in_seconds(hours)
  return hours * 60 * 60
end

DATE_TO_AVOID_DSL_PROBLEMS = '1/01/0001'

describe Time do
  describe '#count_forward_to' do
    it 'counts duration properly when both times are in AM' do
      Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 10am").count_forward_to(Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 11:30am")).must_equal hours_in_seconds(1.5)
    end
    it 'counts duration properly when both times are in PM' do
      Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 10pm").count_forward_to(Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 11:30pm")).must_equal hours_in_seconds(1.5)
    end
    it 'counts duration properly when it crosses from AM to PM' do
      Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 11am").count_forward_to(Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 12:30pm")).must_equal hours_in_seconds(1.5)
    end
    it 'counts duration properly when it crosses from PM to AM' do
      Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 11pm").count_forward_to(Chronic.parse("#{DATE_TO_AVOID_DSL_PROBLEMS} 12:30am")).must_equal hours_in_seconds(1.5)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
time_distribution-2.3.1 spec/time_spec.rb
time_distribution-2.3.0 spec/time_spec.rb
time_distribution-2.2.0 spec/time_spec.rb
time_distribution-2.1.3 spec/time_spec.rb