$:.unshift File.dirname(__FILE__) require 'common_templatelet_test' $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib') require 'buildmaster/template_runner' module BuildMaster class MySite < SiteSpec def load_document(path) content = < Title One Today Title Two Tomorrow CONTENT return REXML::Document.new(content) end end context 'EachTest' do include HelperMethods specify 'should_iteration_through_selected_elements' do template_content = <

CONTENT target = create_element('test') template = REXML::XPath.first(REXML::Document.new(template_content), '/each') site = MySite.new(@site_spec, @cotta) each_processor = Each.new(site) each_processor.process(target, template, SourceContent.new('doc/doc.html', nil)) REXML::XPath.first(target, 'div').attributes['class'].should_equal 'NewsItem' REXML::XPath.match(target, 'div').size.should_equal 2 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)) REXML::XPath.first(target, 'div').attributes['class'].should_equal 'NewsItem' REXML::XPath.match(target, 'div').size.should_equal 2 end end end