Sha256: 87dea5907a87af81a83fd83da3e131f9afc9018375ee81dc49a0e67aac18aae8
Contents?: true
Size: 1.79 KB
Versions: 4
Compression:
Stored size: 1.79 KB
Contents
include DaruLite describe DaruLite::DateTimeIndexHelper do describe '.infer_offset' do subject(:offset) { DaruLite::DateTimeIndexHelper.infer_offset(data) } context 'when the dataset does not have a regular offset' do let(:data) do [ DateTime.new(2020, 1, 1, 00, 00, 00), DateTime.new(2020, 1, 1, 00, 01, 00), DateTime.new(2020, 1, 1, 00, 05, 00), ] end it 'returns nil' do expect(offset).to be_nil end end context 'when the dataset matches a defined offset' do let(:data) do [ DateTime.new(2020, 1, 1, 00, 00, 00), DateTime.new(2020, 1, 1, 00, 01, 00), DateTime.new(2020, 1, 1, 00, 02, 00), ] end it 'returns the matched offset' do expect(offset).to be_an_instance_of(DaruLite::Offsets::Minute) end end context 'when the offset is a multiple of seconds' do let(:data) do [ DateTime.new(2020, 1, 1, 00, 00, 00), DateTime.new(2020, 1, 1, 00, 00, 03), DateTime.new(2020, 1, 1, 00, 00, 06), ] end let(:expected_offset) { DaruLite::Offsets::Second.new(3) } it 'returns a Second offset' do expect(offset).to be_an_instance_of(DaruLite::Offsets::Second) end it 'has the correct multiplier' do expect(offset.freq_string).to eql(expected_offset.freq_string) end end context 'when the offset is less than a second' do let(:data) do [ DateTime.new(2020, 1, 1, 00, 00, 00) + 0.00001, DateTime.new(2020, 1, 1, 00, 00, 00) + 0.00002, DateTime.new(2020, 1, 1, 00, 00, 00) + 0.00003, ] end it 'returns nil' do expect(offset).to be_nil end end end end
Version data entries
4 entries across 4 versions & 1 rubygems