0
- @current_time_class = ActiveReload::RelativeTimeHelpers.time class"
0
- ActiveReload::RelativeTimeHelpers.time_class = Time
0
- Time.stubs(:now).returns(Time.utc(2007, 6, 1, 11))
0
+describe "to_ordinalized_s" do
0
- ActiveReload::RelativeTimeHelpers.time_class = @current time_class"
0
+ @date = Date.parse('2008-5-3')
0
+ @time = Time.parse('2008-5-3 14:00')
0
- it "Should show_today" do
0
- assert_equal 'today', relative_date(Time.now.utc)
0
- it "Should show_yesterday" do
0
- assert_equal 'yesterday', relative_date(1.day.ago.utc)
0
- it "Should show_tomorrow" do
0
- assert_equal 'tomorrow', relative_date(1.day.from_now.utc)
0
+ it "should render a date using #to_s if no format is passed" do
0
+ @date.to_ordinalized_s.should == @date.to_s
0
- it "Should show_date_with_year" do
0
- assert_equal 'Nov 15th, 2005', relative_date(Time.utc(2005, 11, 15))
0
+ it "should render a time using #to_s if no format is passed" do
0
+ @time.to_ordinalized_s.should == @time.to_s
0
- it "Should show_date" do
0
- assert_equal 'Nov 15th', relative_date(Time.utc(2007, 11, 15))
0
+ it "should render a date or time using the db format" do
0
+ @date.to_ordinalized_s(:db).should == "2008-05-03 00:00:00"
0
+ @time.to_ordinalized_s(:db).should == "2008-05-03 14:00:00"
0
- it "Should show_date_span_on_the_same_day" do
0
- assert_equal 'Nov 15th', relative_date_span([Time.utc(2007, 11, 15), Time.utc(2007, 11, 15)])
0
+ it "should render a date or time using the long format" do
0
+ @date.to_ordinalized_s(:long).should == "May 3rd, 2008 00:00"
0
+ @time.to_ordinalized_s(:long).should == "May 3rd, 2008 14:00"
0
- it "Should show_date_span_on_the_same_day_on_different_year" do
0
- assert_equal 'Nov 15th, 2006', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2006, 11, 15)])
0
+ it "should render a date or time using the time format" do
0
+ @date.to_ordinalized_s(:time).should == "00:00"
0
+ @time.to_ordinalized_s(:time).should == "14:00"
0
- it "Should show_date_span_on_the_same_month" do
0
- assert_equal 'Nov 15th - 16th', relative_date_span([Time.utc(2007, 11, 15), Time.utc(2007, 11, 16)])
0
- assert_equal 'Nov 15th - 16th', relative_date_span([Time.utc(2007, 11, 16), Time.utc(2007, 11, 15)])
0
+ it "should render a date or a time using the short format" do
0
+ @date.to_ordinalized_s(:short).should == "3rd May 00:00"
0
+ @time.to_ordinalized_s(:short).should == "3rd May 14:00"
0
- it "Should show_date_span_on_the_same_month_on_different_year" do
0
- assert_equal 'Nov 15th - 16th, 2006', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2006, 11, 16)])
0
- assert_equal 'Nov 15th - 16th, 2006', relative_date_span([Time.utc(2006, 11, 16), Time.utc(2006, 11, 15)])
0
- it "Should show_date_span_on_the_different_month" do
0
- assert_equal 'Nov 15th - Dec 16th', relative_date_span([Time.utc(2007, 11, 15), Time.utc(2007, 12, 16)])
0
- assert_equal 'Nov 15th - Dec 16th', relative_date_span([Time.utc(2007, 12, 16), Time.utc(2007, 11, 15)])
0
- it "Should show_date_span_on_the_different_month_on_different_year" do
0
- assert_equal 'Nov 15th - Dec 16th, 2006', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2006, 12, 16)])
0
- assert_equal 'Nov 15th - Dec 16th, 2006', relative_date_span([Time.utc(2006, 12, 16), Time.utc(2006, 11, 15)])
0
- it "Should show_date_span_on_the_different_year" do
0
- assert_equal 'Nov 15th, 2006 - Dec 16th, 2007', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2007, 12, 16)])
0
- assert_equal 'Nov 15th, 2006 - Dec 16th, 2007', relative_date_span([Time.utc(2007, 12, 16), Time.utc(2006, 11, 15)])
0
- it "Should show_time_span_on_the_same_day_with_same_time" do
0
- assert_equal '5:00 PM Nov 15th', relative_time_span([Time.utc(2007, 11, 15, 17, 00, 00), Time.utc(2007, 11, 15, 17, 00, 00)])
0
- it "Should show_time_span_on_the_same_day_with_same_time_on_different_year" do
0
- assert_equal '5:00 PM Nov 15th, 2006', relative_time_span([Time.utc(2006, 11, 15, 17, 0), Time.utc(2006, 11, 15, 17, 0)])
0
- it "Should show_time_span_on_the_same_day_with_different_times_in_same_half_of_day" do
0
- assert_equal '10:00 - 11:00 AM Nov 15th', relative_time_span([Time.utc(2007, 11, 15, 10), Time.utc(2007, 11, 15, 11, 0)])
0
- it "Should show_time_span_on_the_same_day_with_different_times_in_different_half_of_day" do
0
- assert_equal '10:00 AM - 2:00 PM Nov 15th', relative_time_span([Time.utc(2007, 11, 15, 10, 0), Time.utc(2007, 11, 15, 14, 0)])
0
- it "Should show_time_span_on_the_same_day_with_different_times_in_different_half_of_day_in_different_year" do
0
- assert_equal '10:00 AM - 2:00 PM Nov 15th, 2006', relative_time_span([Time.utc(2006, 11, 15, 10, 0), Time.utc(2006, 11, 15, 14, 0)])
0
- it "Should show_time_span_on_different_days_in_same_year" do
0
- assert_equal '10:00 AM Nov 15th - 2:00 PM Dec 16th, 2006', relative_time_span([Time.utc(2006, 11, 15, 10, 0), Time.utc(2006, 12, 16, 14, 0)])
0
- it "Should show_time_span_on_different_days_in_different_years" do
0
- assert_equal '10:00 AM Nov 15th, 2006 - 2:00 PM Dec 16th, 2007', relative_time_span([Time.utc(2006, 11, 15, 10, 0), Time.utc(2007, 12, 16, 14, 0)])
0
- it "Should show_time_span_on_different_days_in_current_year" do
0
- assert_equal '10:00 AM Nov 15th - 2:00 PM Dec 16th', relative_time_span([Time.utc(2007, 11, 15, 10, 0), Time.utc(2007, 12, 16, 14, 0)])
0
- it "Should not_show_leading_zero_in_hour" do
0
- assert_equal '2:00 PM', prettier_time(Time.utc(2007, 11, 15, 14, 0))
0
- it "Should convert_to_12_hour_time" do
0
- assert_equal '2:00 AM', prettier_time(Time.utc(2007, 11, 15, 2, 0))
0
- it "Should handle_midnight_correctly" do
0
- assert_equal '12:00 AM', prettier_time(Time.utc(2007, 11, 15, 0, 0))