proper test for multi-region requiring
This commit is contained in:
parent
debbf6d411
commit
f62d0780f5
2 changed files with 7 additions and 3 deletions
|
@ -252,6 +252,8 @@ private
|
|||
# Found sub region wild-card
|
||||
regions.delete_if do |reg|
|
||||
if reg.to_s =~ /_$/
|
||||
prefix = reg.to_s.split('_').first
|
||||
raise UnknownRegionError unless @@regions.include?(prefix.to_sym) or begin require "holidays/#{prefix}"; rescue LoadError; false; end
|
||||
regions << @@regions.select { |dr| dr.to_s =~ Regexp.new("^#{reg}") }
|
||||
true
|
||||
end
|
||||
|
@ -261,7 +263,7 @@ private
|
|||
|
||||
require "holidays/north_america" if regions.include?(:us) # special case for north_america/US cross-linking
|
||||
|
||||
raise UnknownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) or begin require "holidays/#{r.to_s.split('_').first}"; rescue LoadError; false; end }
|
||||
raise UnknownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) or begin require "holidays/#{r.to_s}"; rescue LoadError; false; end }
|
||||
regions
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
require File.dirname(__FILE__) + '/test_helper'
|
||||
require 'holidays/gb'
|
||||
require 'holidays/ie'
|
||||
|
||||
class MultipleRegionsTests < Test::Unit::TestCase
|
||||
def setup
|
||||
|
@ -11,6 +9,10 @@ class MultipleRegionsTests < Test::Unit::TestCase
|
|||
h = Holidays.on(Date.civil(2008,12,26), :ie)
|
||||
assert_equal 'St. Stephen\'s Day', h[0][:name]
|
||||
|
||||
h = Holidays.on(Date.civil(2008,5,9), :gb_)
|
||||
assert_equal 'Liberation Day', (h[0] || {})[:name]
|
||||
|
||||
|
||||
h = Holidays.on(Date.civil(2008,5,9), :je)
|
||||
assert_equal 'Liberation Day', h[0][:name]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue