Sha256: 9503d75757789fc0786329996b50dafdb59937267aadc48acd779c04f0737329

Contents?: true

Size: 794 Bytes

Versions: 4

Compression:

Stored size: 794 Bytes

Contents

require 'spec_helper'

describe ::SlideRule::DistanceCalculators::DayOfYear do
  context 'when dates are an exact match' do
    it 'should return a 0 distance' do
      expect(described_class.new.calculate('2015-10-8', '2015-10-8')).to eq(0.0)
    end

    it 'should accept epoch date' do
      expect(described_class.new.calculate(1_444_262_400, 1_444_262_400)).to eq(0.0)
    end
  end

  context 'when dates are more than a year apart' do
    it 'should return a 1 distance' do
      expect(described_class.new.calculate('2015-10-8', '2016-10-8')).to eq(1)
    end
  end

  context 'when dates are in the same year but different' do
    it 'should return a calculated distance distance' do
      expect(described_class.new.calculate('2015-10-8', '2015-11-8')).to eq(0.08)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
slide_rule-0.2.2 spec/slide_rule/distance_calculators/day_of_year_spec.rb
slide_rule-0.2.1 spec/slide_rule/distance_calculators/day_of_year_spec.rb
slide_rule-0.1.2 spec/slide_rule/distance_calculators/day_of_year_spec.rb
slide_rule-0.1.1 spec/slide_rule/distance_calculators/day_of_year_spec.rb