Class: Holidays::Definition::Decorator::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/holidays/definition/decorator/test.rb

Instance Method Summary collapse

Instance Method Details

#call(t) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/holidays/definition/decorator/test.rb', line 5

def call(t)
  src = ""

  t.dates.each do |d|
    date = "Date.civil(#{d.year}, #{d.month}, #{d.day})"

    holiday_call = "Holidays.on(#{date}, #{t.regions}"

    if t.options
      holiday_call += ", #{decorate_options(t.options)}"
    end

    if t.holiday?
      src += "assert_equal \"#{t.name}\", (#{holiday_call})[0] || {})[:name]\n"
    else
      src += "assert_nil (#{holiday_call})[0] || {})[:name]\n"
    end
  end

  src
end