# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 require File.dirname(__FILE__) + '/../../../spec_helper' module RTM::Sugar::TopicMap module Resolve describe self do before(:each) do @tm = get_used_tm_sys_tm @tm.from_xtm(File.dirname(__FILE__) + "/../../../resources/toyTM.xtm") @tm.add_prefix("wiki", "http://en.wikipedia.org/wiki/") end after(:each) do @tm.close end describe "#deresolve" do it "should deresolve an xsd-Locator" do topic = @tm.get("wiki:Germany") topic.should_not be_nil locator = topic["wiki:Population"].first.datatype locator.should_not be_nil result = @tm.deresolve(locator) result.should == "xsd:long" end it "should deresolve a wiki-Iri" do @tm.deresolve("http://en.wikipedia.org/wiki/Belgium").should == "wiki:Belgium" end it "should not deresolve if the prefix does not occurr at the beginning of the identifier" do @tm.deresolve("testhttp://en.wikipedia.org/wiki/Berlin").should == "testhttp://en.wikipedia.org/wiki/Berlin" end it "should deresolve iris starting with 'ii:'" do @tm.deresolve("ii:http://en.wikipedia.org/wiki/Belgium").should == "wiki:Belgium" end it "should deresolve iris starting with '^'" do @tm.deresolve("^http://en.wikipedia.org/wiki/Belgium").should == "wiki:Belgium" end it "should deresolve iris starting with 'sl:'" do @tm.deresolve("sl:http://en.wikipedia.org/wiki/Belgium").should == "wiki:Belgium" end it "should deresolve iris starting with '='" do @tm.deresolve("=http://en.wikipedia.org/wiki/Belgium").should == "wiki:Belgium" end it "should deresolve iris starting with 'si:'" do @tm.deresolve("si:http://en.wikipedia.org/wiki/Belgium").should == "wiki:Belgium" end it "should deresolve against the base_iri" do @tm.deresolve("http://www.topicmapslab.de/Blubber").should == "Blubber" @tm.deresolve("http://www.topicmapslab.de/#id234").should == "#id234" end end end end end