$:.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/templatelets' module BuildMaster class WhenTest < CommonTemplateletTest def test_should_process_child_when_evaluated_true target = create_element('target') template_content = <

Header

CONTENT template_document = REXML::Document.new(template_content) template = REXML::XPath.first(template_document, '/when') when_processor = When.new(self, self) when_processor.process(target, template, self) actual = REXML::XPath.first(target, 'h1') assert_equal('Header', actual.text) end def test_should_not_process_child_when_evaluated_false target = create_element('target') template_content = <

Header

CONTENT template_document = REXML::Document.new(template_content) template = REXML::XPath.first(template_document, '/when') when_processor = When.new(self, self) when_processor.process(target, template, self) assert_equal(0, target.size) end def path return Pathname.new('index.html') end def expression_for_true(path) return true end def expression_for_false(path) return false end def load_templatelets return Hash.new end end end