class Holidays::Definition::Generator::Test
def call(module_name, file_names, tests)
def call(module_name, file_names, tests) validate!(module_name, file_names, tests) test_src =<<-EndOfTests ng: utf-8 File.expand_path(File.dirname(__FILE__)) + '/../test_helper' ile is generated by the Ruby Holiday gem. tions loaded: #{file_names.join(', ')} module_name.to_s.capitalize}DefinitionTests < Test::Unit::TestCase # :nodoc: st_#{module_name.to_s.downcase}#{decorate(tests)} ts test_src end
def decorate(tests)
def decorate(tests) out = "" tests.each do |t| out << "\n " + @decorator.call(t) end out end
def initialize(decorator)
def initialize(decorator) @decorator = decorator end
def validate!(module_name, file_names, tests)
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