diff --git a/lib/holidays.rb b/lib/holidays.rb index 3b722c7..b818ed0 100644 --- a/lib/holidays.rb +++ b/lib/holidays.rb @@ -141,7 +141,7 @@ module Holidays end end - holidays + holidays.sort{|a, b| a[:date] <=> b[:date] } end # Merge a new set of definitions into the Holidays module. diff --git a/test/test_holidays.rb b/test/test_holidays.rb index c62be1f..8baa2ae 100644 --- a/test/test_holidays.rb +++ b/test/test_holidays.rb @@ -114,4 +114,15 @@ class HolidaysTests < Test::Unit::TestCase assert_equal 'Easter Monday', Holidays.on(date, :ca_qc, :informal)[0][:name] end end + + def test_sorting + (1..10).each{|year| + (1..12).each{|month| + holidays = Holidays.between(Date.civil(year, month, 1), Date.civil(year, month, 28), :gb_) + holidays.each_with_index{|holiday, index| + assert holiday[:date] >= holidays[index - 1][:date] if index > 0 + } + } + } + end end