Skip to content

Commit

Permalink
Test for joins and utf-8 escapes instead of normalization.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Jul 8, 2010
1 parent 5a853dc commit bd7fd80
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
29 changes: 21 additions & 8 deletions spec/uri_spec.rb
Expand Up @@ -17,22 +17,35 @@
subject.join(RDF::URI.new("foo#bar")).to_s.should == "http://example.org/foo#bar"
end

describe "normalization" do
describe "utf-8 escaped" do
{
%w(http://foo ) => "http://foo/",
%(http://a/D%C3%BCrst) => %("http://a/D%C3%BCrst"),
%(http://a/D\u00FCrst) => %("http://a/D\\\\u00FCrst"),
%(http://b/Dürst) => %("http://b/D\\\\u00FCrst"),
%(http://a/\u{15678}another) => %("http://a/\\\\U00015678another"),
}.each_pair do |uri, dump|
it "should dump #{uri} as #{dump}" do
RDF::URI.new(uri).to_s.dump.should == dump
end
end
end if defined?(::Encoding) # Only works properly in Ruby 1.9

describe "join" do
{
%w(http://foo ) => "http://foo",
%w(http://foo a) => "http://foo/a",
%w(http://foo /a) => "http://foo/a",
%w(http://foo #a) => "http://foo/#a",
%w(http://foo #a) => "http://foo#a",

%w(http://foo/ ) => "http://foo/",
%w(http://foo/ a) => "http://foo/a",
%w(http://foo/ /a) => "http://foo/a",
%w(http://foo/ #a) => "http://foo/#a",

%w(http://foo# ) => "http://foo/", # Special case for Addressable
%w(http://foo# ) => "http://foo#",
%w(http://foo# a) => "http://foo/a",
%w(http://foo# /a) => "http://foo/a",
%w(http://foo# #a) => "http://foo/#a",
%w(http://foo# #a) => "http://foo#a",

%w(http://foo/bar ) => "http://foo/bar",
%w(http://foo/bar a) => "http://foo/a",
Expand All @@ -44,16 +57,16 @@
%w(http://foo/bar/ /a) => "http://foo/a",
%w(http://foo/bar/ #a) => "http://foo/bar/#a",

%w(http://foo/bar# ) => "http://foo/bar",
%w(http://foo/bar# ) => "http://foo/bar#",
%w(http://foo/bar# a) => "http://foo/a",
%w(http://foo/bar# /a) => "http://foo/a",
%w(http://foo/bar# #a) => "http://foo/bar#a",

%w(http://foo/bar# #D%C3%BCrst) => "http://foo/bar#D%C3%BCrst",
%w(http://foo/bar# #Dürst) => "http://foo/bar#D%C3%BCrst",
%w(http://foo/bar# #Dürst) => "http://foo/bar#D\\u00FCrst",
}.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).normalize.to_s.should == result
RDF::URI.new(input[0]).join(input[1].to_s).to_s.should == result
end
end
end
Expand Down
1 change: 0 additions & 1 deletion spec/writer_spec.rb
Expand Up @@ -290,7 +290,6 @@ class FOO < RDF::Vocabulary("http://foo/"); end
end
end

# FIXME
describe "with default namespace" do
it "should serialize with default namespace" do
@graph << [RDF::URI.new("http://release/"), RDF.type, FOO.Release]
Expand Down

0 comments on commit bd7fd80

Please sign in to comment.