Sha256: 5b75269fdba31dc3411a0a21644b83873f7d05ed7cb0536f9f10646c3ba69951
Contents?: true
Size: 1.59 KB
Versions: 2
Compression:
Stored size: 1.59 KB
Contents
$:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib") require 'rexml/xpath' require 'rexml/document' require 'test/unit' require 'buildmaster/template_runner' module BuildMaster class TemplateRunnerTest < Test::Unit::TestCase def test_process_element_in_document target_content = <<END <html> <h1/> </html> END template_content = <<END <html xmlns="http://www.w3.org/1999/xhtml" xmlns:template="http://buildmaster.rubyforge.org/xtemplate/1.0"> <p> <template:include elements="./name/text()"/> </p> </html> END source_content = <<END <persons> <person id="1"><name>Name One</name></person> <person id="2"><name>Name Two</name></person> </persons> END target_xml = REXML::Document.new(target_content) target_element = REXML::XPath.first(target_xml, '/html/h1') template_element = REXML::XPath.first(REXML::Document.new(template_content), "/html/p") source_xml = REXML::Document.new(source_content) source_element = REXML::XPath.first(source_xml, '/persons/person[@id="1"]') # puts "========= TARGET =========" # puts target_element # puts "========== TEMPLATE ==========" # puts template_element # puts "========== SOURCE ===========" # puts source_element # puts '=========== Source Match ============' # puts REXML::XPath.first(source_element, './name') runner = TemplateRunner.new(target_element, template_element, source_element) runner.process assert_equal('Name One', REXML::XPath.first(REXML::Document.new(target_xml.to_s), '/html/h1/text()').value.strip) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
BuildMaster-0.5.0 | test/buildmaster/tc_template_runner.rb |
BuildMaster-0.6.0 | test/buildmaster/tc_template_runner.rb |