require File.join(File.dirname(__FILE__), "test_helper") class TestLibXMLTestHelper < Test::Unit::TestCase include LibXMLTestHelper #testing the convenience methods! def test_remove_nodes input_xml=<<-END 32 END #test remove only first node expected_xml=<<-END END assert_equal expected_xml.gsub(/\n\W*/, ''), remove_first_node_called('food', input_xml).gsub(/\n\W*/, '') #test remove all nodes expected_xml=<<-END END assert_equal expected_xml.gsub(/\n\W*/, ''), remove_nodes_called('food', input_xml).gsub(/\n\W*/, '') end #testing the convenience methods! def test_replace_nodes input_xml=<<-END 32 END #test replace only first node expected_xml=<<-END END replacement_string = "" output = replace_nodes_called('food', input_xml, replacement_string, true) assert_equal expected_xml.gsub(/\n\W*/, ''), output.gsub(/\n\W*/, '') output = replace_first_node_called('food', input_xml, replacement_string) assert_equal expected_xml.gsub(/\n\W*/, ''), output.gsub(/\n\W*/, '') #test replace all matching nodes expected_xml=<<-END END output = replace_nodes_called('food', input_xml, replacement_string, false) assert_equal expected_xml.gsub(/\n\W*/, ''), output.gsub(/\n\W*/, '') end end