# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 require File.dirname(__FILE__) + '/../../../spec_helper' module RTM::Role describe self do before(:each) do @tm = get_used_tm_sys_tm end after(:each) do @tm.close end describe "#parent" do it "should give back the Association to which this Role belongs" do topic = @tm.create_topic_by("Haus") topic.should be_a_kind_of(RTM::Topic) @tm.get("Haus").should be_a_kind_of(RTM::Topic) topic_instance = @tm.create_topic_by("Weisses_Haus") topic_instance.should be_a_kind_of RTM::Topic @tm.get("Weisses_Haus").should be_a_kind_of(RTM::Topic) testassoc = @tm.create_association("Haus-Nummer-Beziehung") testrole = testassoc.create_role(topic, topic_instance) #TMAPI function testassoc.should be_a_kind_of(RTM::Association) testrole.should be_a_kind_of(RTM::Role) testrole.parent.should == testassoc end end describe "#player=" do before(:each) do assoc = @tm.create_association("mother_child") @role = assoc.create_role("child","Hans") @role.should be_a_kind_of RTM::Role end it "should set the player of the Role if identifier is a String" do previous_player = @role.player @role.player = "Tim" @role.player.should_not == previous_player @role.player.should == @tm.get("Tim") end it "should set the player of the Role if identifier is a Locator" do previous_player = @role.player @role.player = @tm.create_locator("Tim") @role.player.should_not == previous_player @role.player.should == @tm.get("Tim") end it "should set the player of the Role if identifier is a Topic" do previous_player = @role.player @role.player = @tm.get!("Tim") @role.player.should_not == previous_player @role.player.should == @tm.get("Tim") end end describe "#remove" do before(:each) do @assoc = @tm.create_association("assoc") @role1 = @assoc.create_role("r1","t1") @role2 = @assoc.create_role("r2","t2") end it "should remove this Role from the container (Association)" do @assoc.should have(2).children @role1.remove @assoc.should have(1).children @role2.remove @assoc.should have(0).children end end end # of describe self end #of module