Sha256: df8eed81aa648e745177b7d2e4c6a6f9d37d06a54fb0b0b76424328e1a3b94f3

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

# encoding: utf-8

require_relative "../../../spec_helper"

describe "#strftime_ordinalized" do

  before(:all) do
    @date = Date.parse('2008-5-3')
    @time = Time.parse('2008-5-3 14:00')
  end

  it "should ordinalize a date even without a locale passed" do
    @date.strftime_ordinalized('%b %d, %Y').should == "May 3rd, 2008"
  end

end

describe "to_ordinalized_s" do

  before(:each) do
    @date = Date.parse('2008-5-3')
    @time = Time.parse('2008-5-3 14:00')
  end

  it "should render a date using #to_s if no format is passed" do
    @date.to_ordinalized_s.should == @date.to_s
  end

  it "should render a time using #to_s if no format is passed" do
    @time.to_ordinalized_s.should == @time.to_s
  end

  it "should render a date or time using the db format" do
    @date.to_ordinalized_s(:db).should == "2008-05-03 00:00:00"
    @time.to_ordinalized_s(:db).should == "2008-05-03 14:00:00"
  end

  it "should render a date or time using the long format" do
    @date.to_ordinalized_s(:long).should == "May 3rd, 2008 00:00"
    @time.to_ordinalized_s(:long).should == "May 3rd, 2008 14:00"
  end

  it "should render a date or time using the time format" do
    @date.to_ordinalized_s(:time).should == "00:00"
    @time.to_ordinalized_s(:time).should == "14:00"
  end

  it "should render a date or a time using the short format" do
    @date.to_ordinalized_s(:short).should == "3rd May 00:00"
    @time.to_ordinalized_s(:short).should == "3rd May 14:00"
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rango-0.0.4 spec/rango/helpers/merb-helpers/ordinalize_spec.rb