test/buildmaster/templatelets/tc_each.rb in BuildMaster-0.8.1 vs test/buildmaster/templatelets/tc_each.rb in BuildMaster-0.9.0

- old
+ new

@@ -6,27 +6,47 @@ require 'buildmaster/template_runner' module BuildMaster -class EachTest < CommonTemplateletTest - def test_should_iteration_through_selected_elements +class MySite < SiteSpec + def load_document(path) + content = <<CONTENT +<rss> + <item> + <title>Title One</title> + <pubDate>Today</pubDate> + </item> + <item> + <title>Title Two</title> + <pubDate>Tomorrow</pubDate> + </item> +</rss> +CONTENT + + return REXML::Document.new(content) + end +end + +context 'EachTest' do + include HelperMethods + specify 'should_iteration_through_selected_elements' do template_content = <<CONTENT <each source="rss" select="/rss/item" count="2"> <div class="NewsItem"> <p class="Title"><include elements="./title/text()"/></p> <p class="Date"><include elements="./pubDate/text()"/></p> </div> </each> CONTENT target = create_element('test') template = REXML::XPath.first(REXML::Document.new(template_content), '/each') - site = MySite.new + site = MySite.new(@site_spec, @cotta) 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) + 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 <each source="http://localhost:2000/news-rss2.xml" select="/rss/item" count="2"> @@ -39,31 +59,12 @@ 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) + REXML::XPath.first(target, 'div').attributes['class'].should_equal 'NewsItem' + REXML::XPath.match(target, 'div').size.should_equal 2 - end -end - -class MySite < SiteSpec - def load_document(path) - content = <<CONTENT -<rss> - <item> - <title>Title One</title> - <pubDate>Today</pubDate> - </item> - <item> - <title>Title Two</title> - <pubDate>Tomorrow</pubDate> - </item> -</rss> -CONTENT - - return REXML::Document.new(content) end end end \ No newline at end of file