spec/uri_spec.rb in rdf-rdfxml-0.2.2 vs spec/uri_spec.rb in rdf-rdfxml-0.2.2.1

- old
+ new

@@ -1,9 +1,14 @@ # coding: utf-8 +$:.unshift "." require File.join(File.dirname(__FILE__), 'spec_helper') describe RDF::URI do + class EXa < RDF::Vocabulary("http://example.org/foo/"); end + class EXb < RDF::Vocabulary("http://example.org/foo#"); end + class EXc < RDF::Vocabulary("http://example.org/foo"); end + subject { RDF::URI.new("http://example.org")} context "join" do it "should append fragment to uri" do subject.join("foo").to_s.should == "http://example.org/foo" @@ -67,8 +72,38 @@ }.each_pair do |input, result| it "should create <#{result}> from <#{input[0]}> and '#{input[1]}'" do RDF::URI.new(input[0]).join(input[1].to_s).to_ntriples.should == result end end + end + end + + context "qname" do + it "should create [:rdf, :foo]" do + RDF.foo.qname.should == [:rdf, :foo] + end + + it "should create [:rdfs, nil]" do + RDF::RDFS.to_uri.qname.should == [:rdfs, nil] + end + + it "should find with trailing /" do + EXa.bar.qname.should == [:exa, :bar] + end + + it "should find with trailing #" do + EXb.bar.qname.should == [:exb, :bar] + end + + it "should find with trailing word" do + EXc.bar.qname.should == [:exc, :bar] + end + end + + context "vocab" do + RDF::Vocabulary.each do |v| + specify {v.foo.vocab.should == v} + specify {v.foo.vocab.to_uri.to_s.should == v.to_uri.to_s} + specify {v.to_s.should == v.to_uri.to_s} unless v == RDF end end end