diff options
Diffstat (limited to 'spec/ruby/shared/time')
| -rw-r--r-- | spec/ruby/shared/time/strftime_for_time.rb | 8 | ||||
| -rw-r--r-- | spec/ruby/shared/time/yday.rb | 18 |
2 files changed, 26 insertions, 0 deletions
diff --git a/spec/ruby/shared/time/strftime_for_time.rb b/spec/ruby/shared/time/strftime_for_time.rb index 49cd09051a..9f4d08d72e 100644 --- a/spec/ruby/shared/time/strftime_for_time.rb +++ b/spec/ruby/shared/time/strftime_for_time.rb @@ -170,4 +170,12 @@ describe :strftime_time, shared: true do time.strftime("%-k%p").should == "8AM" time.strftime("%-l%p").should == "8AM" end + + it "should be able to show default Logger format" do + default_logger_format = "%Y-%m-%dT%H:%M:%S.%6N " + @new_time[2001, 2, 3, 4, 5, 6].strftime(default_logger_format).should == "2001-02-03T04:05:06.000000 " + @new_time[2001, 12, 3, 4, 5, 6 + 1/10r].strftime(default_logger_format).should == "2001-12-03T04:05:06.100000 " + @new_time[2001, 2, 13, 4, 5, 6 + 1/100r].strftime(default_logger_format).should == "2001-02-13T04:05:06.010000 " + @new_time[2001, 2, 3, 14, 5, 6 + 1/1000r].strftime(default_logger_format).should == "2001-02-03T14:05:06.001000 " + end end diff --git a/spec/ruby/shared/time/yday.rb b/spec/ruby/shared/time/yday.rb new file mode 100644 index 0000000000..f81c45261c --- /dev/null +++ b/spec/ruby/shared/time/yday.rb @@ -0,0 +1,18 @@ +describe :time_yday, shared: true do + it 'returns the correct value for each day of each month' do + mdays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + + yday = 1 + mdays.each_with_index do |days, month| + days.times do |day| + @method.call(2014, month+1, day+1).should == yday + yday += 1 + end + end + end + + it 'supports leap years' do + @method.call(2016, 2, 29).should == 31 + 29 + @method.call(2016, 3, 1).should == 31 + 29 + 1 + end +end |
