$:.unshift File.dirname(__FILE__) require 'common_templatelet_test' $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib') require 'rexml/document' require 'rexml/xpath' require 'buildmaster/site_spec' require 'buildmaster/source_content' module BuildMaster class TextTest < CommonTemplateletTest def test_should_generate_text_based_on_property target = create_element('target') template = create_element('text') template.attributes['property'] = 'property' text = Text.new({'property' => 'text'}) text.process(target, template, nil) assert_equal('text', target.text) end def test_should_throw_exception_if_property_not_set target = create_element('target') template = create_element('text') template.attributes['property'] = 'one' text = Text.new(Hash.new) begin text.process(target, template, nil) fail('TemplateException should have been thrown') rescue TemplateException => exception assert_equal(true, exception.message.include?('one')) end end end end