$:.unshift File.dirname(__FILE__) require 'common_templatelet_test' $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib') require 'buildmaster/template_runner' module BuildMaster class EachTest < CommonTemplateletTest def test_should_iteration_through_selected_elements template_content = <

CONTENT target = create_element('test') template = REXML::XPath.first(REXML::Document.new(template_content), '/each') site = MySite.new each_processor = Each.new(site) each_processor.process(target, template, SourceContent.new('doc/doc.html', nil)) assert_equal('NewsItem', REXML::XPath.first(target, 'div').attributes['class']) assert_equal(2, REXML::XPath.match(target, 'div').size) end def on_line_test_rss_uri_need_start_a_server template_content = <

CONTENT target = create_element('test') template = REXML::XPath.first(REXML::Document.new(template_content), '/each') site = MySite.new each_processor = Each.new(site) each_processor.process(target, template, SourceContent.new('doc/doc.html', nil)) assert_equal('NewsItem', REXML::XPath.first(target, 'div').attributes['class']) assert_equal(2, REXML::XPath.match(target, 'div').size) end end class MySite < SiteSpec def load_document(path) content = < Title One Today Title Two Tomorrow CONTENT return REXML::Document.new(content) end end end