require File.join(File.dirname(__FILE__), 'spec_helper') require 'rdfa_helper' # Time to add your specs! # http://rspec.info/ describe "RDFa parser" do before(:each) { @parser = RdfaParser.new } it "should parse simple doc" do sampledoc = <<-EOF;
This photo was taken by
EOF @parser.parse(sampledoc, "http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0001.xhtml", :strict => true) @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 .Manu Sporny knows Ralph Swick.
EOF @parser.parse(sampledoc, "http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0011.xhtml", :strict => true) @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 =~ /0115/ #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, :debug => []) 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 =~ /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, :debug => []) end rescue Spec::Expectations::ExpectationNotMetError => e pending() { raise } end end end end end end end