require 'amrita2' require 'amrita2/testsupport' context "normalize xml"do include Amrita2::TestSupport specify "single tag" do normalize("").should == '' normalize("").should == '' end specify "single tag with attributes" do normalize("").should == '' normalize("").should == '' end specify "tag with text" do normalize("xx").should == "\nxx\n" end specify "nested tag" do normalize("").should == "\n\n" end specify "nested tag with text" do normalize("<_>xx").should == "\n<_>\nxx\n\n" end specify "text" do normalize("abc").should == "abc" normalize(" abc ").should == "abc" normalize(" \n abc \n ").should == "abc" normalize(" \n abc \n abc").should == "abc abc" normalize(" \n a b c \n a b c\n").should == "a b c a b c" normalize(" \n a b c \n a b c\n\n").should == "\na b c a b c\n" end specify "single tag with space" do normalize('<_ am:src="title" />').should == '<_ am:src="title" />' normalize(" <_ am:src='title' /> \n").should == '<_ am:src="title">' end end context "should_same_xml_as" do specify "xml" do a = "
ddd
" b = "
ddd
" a.should_be_samexml_as b Amrita2::SanitizedString[a].should_be_samexml_as b end specify "change order of attributes" do a = "
ddd
" a.should_be_samexml_as "
ddd
" end specify "add extra spaces" do a = "
\nddd\n
" b = "
\n\nddd
" a.should_be_samexml_as b end specify "ignore space between tags" do a = "" b = "" a.should_be_samexml_as b end specify "ignore space before tags" do a = "\n aaabbbccc \n" b = "aaabbbccc" a.should_be_samexml_as b a = Amrita2::SanitizedString["\nhook can write to stream direct
hook can render self
and add anything after that\n"] b = "hook can write to stream direct
hook can render self
and add anything after that" a.should_be_samexml_as b end specify "ignore newlines" do a = "Red

eyes " b = "Red
eyes" a.should_be_samexml_as b end end