Sha256: 422d5e2b934b3d4dd6100e0014244cd5181aa0d4c074920fbddc7b38d3a1ee4a
Contents?: true
Size: 1.34 KB
Versions: 4
Compression:
Stored size: 1.34 KB
Contents
require 'spec_helper' describe CalendarSniper::ClassMethods do class TestSniper extend CalendarSniper::ClassMethods end [ [ '%m/%d/%Y', '1/1/2013' ], [ '%m/%d/%Y', '01/1/2013' ], [ '%m/%d/%Y', '1/01/2013' ], [ '%m/%d/%Y', '01/01/2013'], [ '%Y-%m-%d', '2013-01-01'], [ '%Y-%m-%d %Z', '2013-01-01 +01:00' ], [ '%Y-%m-%d %k:%M:%S', '2013-01-01 3:00:00' ], [ '%Y-%m-%d %l:%M:%S%z', '2013-01-01 2:50:00-0400'] ].each do |format, example| it "can parse #{example} as #{format}" do expect(TestSniper.send(:coalesce_date, example, '=')).to eq(Time.strptime(example, format)) end end it 'Uses the default time zone for greater than' do Time.use_zone('Eastern Time (US & Canada)') do dt = TestSniper.send(:coalesce_date, '1/01/2013', :>) expect(dt.zone).to eq('EST') expect(dt.strftime('%Y-%m-%d %H:%M:%S%z')).to eq('2013-01-01 00:00:00-0500') end end it 'Uses the default time zone for less than' do Time.use_zone('Eastern Time (US & Canada)') do dt = TestSniper.send(:coalesce_date, '1/01/2013', :<) expect(dt.zone).to eq('EST') expect(dt.strftime('%Y-%m-%d %H:%M:%S%z')).to eq('2013-01-01 23:59:59-0500') end end it 'fails when there is an invalid string' do expect { TestSniper.send(:date_format_for_string, 'bogus') }.to raise_error end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
calendar_sniper-1.1.7 | spec/parsing_spec.rb |
calendar_sniper-1.1.6 | spec/parsing_spec.rb |
calendar_sniper-1.1.5 | spec/parsing_spec.rb |
calendar_sniper-1.1.3 | spec/parsing_spec.rb |