class Holidays::Definition::Generator::Test
Public Class Methods
new(decorator)
click to toggle source
# File lib/holidays/definition/generator/test.rb, line 7 def initialize(decorator) @decorator = decorator end
Public Instance Methods
call(module_name, file_names, tests)
click to toggle source
# File lib/holidays/definition/generator/test.rb, line 11 def call(module_name, file_names, tests) validate!(module_name, file_names, tests) test_src =<<-EndOfTests require File.expand_path(File.dirname(__FILE__)) + '/../test_helper' # This file is generated by the Ruby Holiday gem. # # Definitions loaded: #{file_names.join(', ')} class #{module_name.to_s.capitalize}DefinitionTests < Test::Unit::TestCase # :nodoc: def test_#{module_name.to_s.downcase}#{decorate(tests)} end end EndOfTests test_src end
Private Instance Methods
decorate(tests)
click to toggle source
# File lib/holidays/definition/generator/test.rb, line 39 def decorate(tests) out = "" tests.each do |t| out << "\n " + @decorator.call(t) end out end
validate!(module_name, file_names, tests)
click to toggle source
# File lib/holidays/definition/generator/test.rb, line 33 def validate!(module_name, file_names, tests) raise ArgumentError.new("module_name cannot be missing") if module_name.nil? || module_name.empty? raise ArgumentError.new("file_names for '#{module_name}' cannot be missing") if file_names.nil? || file_names.empty? raise ArgumentError.new("tests for '#{module_name}' cannot be missing") if tests.nil? end