# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 require File.dirname(__FILE__) + '/../../spec_helper' module RTM::Axes module Characteristics describe self do before(:all) do @tm = get_used_tm_sys_tm @name_value = "Hans" @occ_value = "18" @topic1 = @tm.get!("Person1") @topic2 = @tm.get!("Person2") @topic3 = @tm.get!("Person3") @name1 = @topic1.create_name(@name_value) @name2 = @topic2.create_name("Peter") @name3 = @topic3.create_name(@name_value) @occ1 = @topic1.create_occurrence("Number", @occ_value) @occ2 = @topic2.create_occurrence("Age", @occ_value) @occ3 = @topic3.create_occurrence("Friend", @name_value) @proxy = [@name1.axes,@name3.axes,@occ1.axes,@occ2.axes,@occ3.axes].extend(Characteristics) end after(:all) do @tm.close end it "should be allowed to call #tmapi and #result on a RTM::Axes::Characteristics" do @proxy.methods.should include("tmapi") @proxy.methods.should include("result") end it "should be allowed to call #atomify on a RTM::Axes::Characteristics" do @proxy.methods.should include("atomify") end it "should be allowed to call #reverse_characteristics on a RTM::Axes::Characteristics" do @proxy.methods.should include("reverse_characteristics") end it "should be allowed to call #reverse_reifier on a RTM::Axes::Characteristics" do @proxy.methods.should include("reverse_reifier") end it "should be allowed to call #scope on a RTM::Axes::Characteristics" do @proxy.methods.should include("scope") end describe "#atomify" do it "should give back an Array" do @proxy.atomify.should be_a_kind_of Array end it "should give back an Array consisting of RTM::Axes::String" do @proxy.atomify.first.should be_a_kind_of RTM::Axes::String end it "should give back RTM::TQML::Strings" do @proxy.atomify.should be_a_kind_of RTM::Axes::Strings end it "should give back the values" do @proxy.atomify.size.should == 5 @proxy.atomify.map{|res| res.construct}.should include(@name_value) @proxy.atomify.map{|res| res.construct}.should include(@occ_value) end end describe "#reverse_characteristics" do it "should give back an Array" do @proxy.reverse_characteristics.should be_a_kind_of Array end it "should give back an Array consisting of RTM::Axes::Topic" do @proxy.reverse_characteristics.first.should be_a_kind_of(RTM::Axes::Topic) end it "should give back a RTM::Axes::Topics" do @proxy.reverse_characteristics.should be_a_kind_of RTM::Axes::Topics end it "should give back the right Topics" do @proxy.reverse_characteristics.size.should == 3 #unique @proxy.reverse_characteristics.map{|res| res.construct}.should include(@topic1) @proxy.reverse_characteristics.map{|res| res.construct}.should include(@topic2) @proxy.reverse_characteristics.map{|res| res.construct}.should include(@topic3) @proxy.reverse_characteristics("Number").size.should == 1 @proxy.reverse_characteristics("Number").map{|res| res.construct}.should include(@topic1) end end end end end