spec/literal_spec.rb in rdfa_parser-0.1.2 vs spec/literal_spec.rb in rdfa_parser-0.1.3

- old
+ new

@@ -22,12 +22,12 @@ describe "with extended characters" do subject { Literal.untyped("松本 后子") } describe "encodings" do - it "should return n3" do subject.to_n3.should == '"\u677E\u672C \u540E\u5B50"' end - it "should return ntriples" do subject.to_ntriples.should == '"\u677E\u672C \u540E\u5B50"' end + it "should return n3" do subject.to_n3.should == "\"\\\u677E\\\u672C \\\u540E\\\u5B50\"" end + it "should return ntriples" do subject.to_ntriples.should == "\"\\\u677E\\\u672C \\\u540E\\\u5B50\"" end it "should return xml_args" do subject.xml_args.should == ["松本 后子", {}] end it "should return TriX" do subject.to_trix.should == "<plainLiteral>" + "松本 后子" + "</plainLiteral>" end end end @@ -149,28 +149,28 @@ Literal.typed("foo <sup>bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral", :namespaces => {"dc" => Namespace.new("http://purl.org/dc/elements/1.1/", "dc")}) } describe "encodings" do - it "should return n3" do subject.to_n3.should == "\"foo <sup xmlns:dc=\\\"http://purl.org/dc/elements/1.1/\\\">bar</sup> baz!\"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end + it "should return n3" do subject.to_n3.should == "\"foo <sup>bar</sup> baz!\"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end it "should return ntriples" do subject.to_ntriples.should == subject.to_n3 end - it "should return xml_args" do subject.xml_args.should == ["foo <sup xmlns:dc=\"http://purl.org/dc/elements/1.1/\">bar</sup> baz!", {"rdf:parseType" => "Literal"}] end - it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup xmlns:dc=\"http://purl.org/dc/elements/1.1/\">bar</sup> baz!</typedLiteral>" end + it "should return xml_args" do subject.xml_args.should == ["foo <sup>bar</sup> baz!", {"rdf:parseType" => "Literal"}] end + it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup>bar</sup> baz!</typedLiteral>" end end describe "and language" do subject { Literal.typed("foo <sup>bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral", :namespaces => {"dc" => Namespace.new("http://purl.org/dc/elements/1.1/", "dc")}, :language => "fr") } describe "encodings" do - it "should return n3" do subject.to_n3.should == "\"foo <sup xmlns:dc=\\\"http://purl.org/dc/elements/1.1/\\\" xml:lang=\\\"fr\\\">bar</sup> baz!\"\^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end + it "should return n3" do subject.to_n3.should == "\"foo <sup xml:lang=\\\"fr\\\">bar</sup> baz!\"\^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end it "should return ntriples" do subject.to_ntriples.should == subject.to_n3 end - it "should return xml_args" do subject.xml_args.should == ["foo <sup xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xml:lang=\"fr\">bar</sup> baz!", {"rdf:parseType" => "Literal"}] end - it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xml:lang=\"fr\">bar</sup> baz!</typedLiteral>" end + it "should return xml_args" do subject.xml_args.should == ["foo <sup xml:lang=\"fr\">bar</sup> baz!", {"rdf:parseType" => "Literal"}] end + it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup xml:lang=\"fr\">bar</sup> baz!</typedLiteral>" end end end describe "and language with an existing language embedded" do subject { @@ -208,10 +208,13 @@ </html> ), nil, nil, Nokogiri::XML::ParseOptions::DEFAULT_XML).root content = root.css("h2").children Literal.typed(content, "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral", - :namespaces => {"svg" => Namespace.new("http://www.w3.org/2000/svg", "svg")}) + :namespaces => { + "svg" => Namespace.new("http://www.w3.org/2000/svg", "svg"), + "dc" => Namespace.new("http://purl.org/dc/elements/1.1/", "dc") + }) } it "should return xml_args" do subject.xml_args.should == ["<svg:svg xmlns:svg=\"http://www.w3.org/2000/svg\"></svg:svg>", {"rdf:parseType" => "Literal"}] end end describe "and existing namespace definition" do