# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 require File.dirname(__FILE__) + '/../../../spec_helper' module RTM::Navigation::Association describe self do before(:each) do @tm = get_used_tm_sys_tm end after(:each) do @tm.close end describe "#players" do before(:each) do @assoc = @tm.create_association("assoc_type") end it "give back no players if the association has no players" do @assoc.should have(0).players end it "give back all players of the association" do @assoc.create_role("role_type","role_player") @assoc.should have(1).players @tm.get("role_player").should_not be_nil @assoc.players.should include @tm.get("role_player") end it "should give back a player as many times as it plays a role in the association" do @assoc.create_role("country","germany") @assoc.should have(1).players @tm.get("germany").should_not be_nil @assoc.players.should include @tm.get("germany") @assoc.create_role("neighbour_country","germany") @assoc.should have(2).players @assoc.players.should include @tm.get("germany") end it "should give back players whose roletype equals the optional argument" do @assoc.create_role("country","germany") @assoc.create_role("country","france") @assoc.create_role("neighbouring_country","switzerland") @assoc.should have(3).players @assoc.players("country").size.should == 2 @assoc.players("neighbouring_country").size.should == 1 end it "should give back an empty result if no role with the specified role type exists" do @assoc.create_role("country","germany") @assoc.create_role("country","france") @assoc.create_role("neighbouring_country","switzerland") @assoc.players("countries").should be_empty end it "should give back a container" do @assoc.players.should respond_to(:each) @assoc.players.should_not be_a_kind_of String end end end end