Sha256: 424b70266dceb8af6f30486dd7abfce0ec280c4f27246c69b618436d31899ae0
Contents?: true
Size: 1.75 KB
Versions: 30
Compression:
Stored size: 1.75 KB
Contents
#!/usr/bin/env ruby -w # encoding: UTF-8 # # = FileNameCoder_spec.rb -- Fit4Ruby - FIT file processing library for Ruby # # Copyright (c) 2015 by Chris Schlaeger <cs@taskjuggler.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. # $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'time' require 'fit4ruby/FileNameCoder' describe Fit4Ruby::FileNameCoder do before(:all) do @data = [ [ '2015-10-23T21:18:00+0200', '5ANJ1800.FIT' ], [ '2015-10-11T15:06:59+0000', '5ABF0659.FIT' ], [ '2014-04-19T07:31:06+0100', '44J63106.FIT' ], [ '2015-05-07T16:16:50+0000', '557G1650.FIT' ] ] end it 'should convert a time stamps to a file names' do @data.each do |t| expect(Fit4Ruby::FileNameCoder.encode(Time.parse(t[0]))).to eq(t[1]) end end it 'should convert file names to time stamps' do @data.each do |t| expect(Fit4Ruby::FileNameCoder.decode(t[1])).to eq(Time.parse(t[0]).utc) end end it 'should fail to encode dates before 2010' do expect { Fit4Ruby::FileNameCoder.encode(Time.parse('2009-12-31T00:00')) }.to raise_error(ArgumentError) end it 'should fail to encode dates after 2033' do expect { Fit4Ruby::FileNameCoder.encode(Time.parse('2034-01-01T00:00+00:00')) }.to raise_error(ArgumentError) end it 'should fail to decode illegal file names' do [ 'A.FIT', '0123ABCD', '5ZNJ1800.FIT', '44063106.FIT', '44W63106.FIT', '557O1650.FIT', '557G6050.FIT', '557G1660.FIT' ].each do |name| expect { Fit4Ruby::FileNameCoder.decode(name) }.to raise_error(ArgumentError) end end end
Version data entries
30 entries across 30 versions & 1 rubygems