test/content_test.rb in sablon-0.0.21 vs test/content_test.rb in sablon-0.0.22

- old
+ new

@@ -74,10 +74,11 @@ super @template_text = '<w:p><span>template</span></w:p><w:p>AFTER</w:p>' @document = Nokogiri::XML.fragment(@template_text) @paragraph = @document.children.first @node = @document.css("span").first + @env = Sablon::Environment.new(nil) end private def assert_xml_equal(expected, document) assert_equal expected, document.to_xml(indent: 0, save_with: 0) @@ -86,29 +87,29 @@ class ContentStringTest < Sablon::TestCase include ContentTestSetup def test_single_line_string - Sablon.content(:string, "a normal string").append_to @paragraph, @node + Sablon.content(:string, "a normal string").append_to @paragraph, @node, @env output = <<-XML.strip <w:p><span>template</span><span>a normal string</span></w:p><w:p>AFTER</w:p> XML assert_xml_equal output, @document end def test_numeric_string - Sablon.content(:string, 42).append_to @paragraph, @node + Sablon.content(:string, 42).append_to @paragraph, @node, @env output = <<-XML.strip <w:p><span>template</span><span>42</span></w:p><w:p>AFTER</w:p> XML assert_xml_equal output, @document end def test_string_with_newlines - Sablon.content(:string, "a\nmultiline\n\nstring").append_to @paragraph, @node + Sablon.content(:string, "a\nmultiline\n\nstring").append_to @paragraph, @node, @env output = <<-XML.strip.gsub("\n", "") <w:p> <span>template</span> <span>a</span> @@ -123,27 +124,27 @@ assert_xml_equal output, @document end def test_blank_string - Sablon.content(:string, "").append_to @paragraph, @node + Sablon.content(:string, "").append_to @paragraph, @node, @env assert_xml_equal @template_text, @document end end class ContentWordMLTest < Sablon::TestCase include ContentTestSetup def test_blank_word_ml - Sablon.content(:word_ml, "").append_to @paragraph, @node + Sablon.content(:word_ml, "").append_to @paragraph, @node, @env assert_xml_equal "<w:p>AFTER</w:p>", @document end def test_inserts_word_ml_into_the_document @word_ml = '<w:p><w:r><w:t xml:space="preserve">a </w:t></w:r></w:p>' - Sablon.content(:word_ml, @word_ml).append_to @paragraph, @node + Sablon.content(:word_ml, @word_ml).append_to @paragraph, @node, @env output = <<-XML.strip.gsub("\n", "") <w:p> <w:r><w:t xml:space=\"preserve\">a </w:t></w:r> </w:p>