Sha256: 74927e1b346e89a4d286206d798e2fe740b66db8d34509dc9d04991b42586315

Contents?: true

Size: 1.45 KB

Versions: 22

Compression:

Stored size: 1.45 KB

Contents

require "test_helper"


class CoreExtDateTest < ActiveSupport::TestCase
  
  
  test "should correctly identify the nth weekday of the month of a date" do
    assert_equal 1, Date.new(2012, 7, 1).get_nth_wday_of_month
    assert_equal 1, Date.new(2012, 7, 7).get_nth_wday_of_month
    assert_equal 2, Date.new(2012, 7, 8).get_nth_wday_of_month
    assert_equal 2, Date.new(2012, 7, 14).get_nth_wday_of_month
    assert_equal 3, Date.new(2012, 7, 15).get_nth_wday_of_month
    assert_equal 3, Date.new(2012, 7, 21).get_nth_wday_of_month
    assert_equal 4, Date.new(2012, 7, 22).get_nth_wday_of_month
    assert_equal 4, Date.new(2012, 7, 28).get_nth_wday_of_month
    assert_equal 5, Date.new(2012, 7, 29).get_nth_wday_of_month
  end
  
  test "should correctly identify the nth weekday of the month of a date as a string" do
    assert_equal "1 Sunday", Date.new(2012, 7, 1).get_nth_wday_string
    assert_equal "1 Saturday", Date.new(2012, 7, 7).get_nth_wday_string
    assert_equal "2 Sunday", Date.new(2012, 7, 8).get_nth_wday_string
    assert_equal "2 Saturday", Date.new(2012, 7, 14).get_nth_wday_string
    assert_equal "3 Sunday", Date.new(2012, 7, 15).get_nth_wday_string
    assert_equal "3 Saturday", Date.new(2012, 7, 21).get_nth_wday_string
    assert_equal "4 Sunday", Date.new(2012, 7, 22).get_nth_wday_string
    assert_equal "4 Saturday", Date.new(2012, 7, 28).get_nth_wday_string
    assert_equal "5 Sunday", Date.new(2012, 7, 29).get_nth_wday_string
  end
  
  
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hiccup-0.4.0 test/core_ext_date_test.rb
hiccup-0.3.0 test/core_ext_date_test.rb