require File.join(File.dirname(__FILE__), 'spec_helper') require 'rdfa_helper' # Time to add your specs! # http://rspec.info/ describe "RDFa parser" do it "should parse simple doc" do sampledoc = <<-EOF; Test 0001

This photo was taken by Mark Birbeck.

EOF parser = RdfaParser::RdfaParser.new parser.parse(sampledoc, "http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0001.xhtml") parser.graph.size.should == 1 parser.graph.to_rdfxml.should be_valid_xml end it "should parse XML Literal and generate valid XML" do sampledoc = <<-EOF Test 0011
Author: Albert Einstein

E = mc2: The Most Urgent Problem of Our Time

EOF parser = RdfaParser::RdfaParser.new parser.parse(sampledoc, "http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0011.xhtml") parser.graph.size.should == 2 xml = parser.graph.to_rdfxml xml.should be_valid_xml # Ensure that enclosed literal is also valid xml.should include("E = mc2: The Most Urgent Problem of Our Time") end it "should parse BNodes" do sampledoc = <<-EOF Test 0017

Manu Sporny knows Ralph Swick.

EOF parser = RdfaParser::RdfaParser.new parser.parse(sampledoc, "http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0011.xhtml") parser.graph.size.should == 3 xml = parser.graph.to_rdfxml xml.should be_valid_xml xml.should include("Ralph Swick") xml.should include("Manu Sporny") end def self.test_cases(suite) RdfaHelper::TestCase.test_cases(suite) end # W3C Test suite from http://www.w3.org/2006/07/SWD/RDFa/testsuite/ %w(xhtml html4 html5).each do |suite| describe "w3c #{suite} testcases" do describe "that are approved" do test_cases(suite).each do |t| next unless t.status == "approved" #next unless t.name =~ /017\d/ #puts t.inspect specify "test #{t.name}: #{t.title}#{", (negative test)" unless t.expectedResults}" do begin t.run_test do |rdfa_string, rdfa_parser| rdfa_parser.parse(rdfa_string, t.informationResourceInput) end rescue Spec::Expectations::ExpectationNotMetError => e raise end end end end describe "that are unreviewed" do test_cases(suite).each do |t| next unless t.status == "unreviewed" #next unless t.name =~ /0092/ #puts t.inspect specify "test #{t.name}: #{t.title}#{", (negative test)" unless t.expectedResults}" do begin t.run_test do |rdfa_string, rdfa_parser| rdfa_parser.parse(rdfa_string, t.informationResourceInput) end rescue Spec::Expectations::ExpectationNotMetError => e pending() { raise } end end end end end end end