Sha256: 9765be7ca413bff3b8eb66aaae526047addf27260e9190eec3c2adfad04007c6

Contents?: true

Size: 1.9 KB

Versions: 5

Compression:

Stored size: 1.9 KB

Contents

# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
# License:   Apache License, Version 2.0

require File.dirname(__FILE__) + '/../../../spec_helper'

module RTM::Navigation::Topic
  describe self do
    before(:each) do
      @tm = get_used_tm_sys_tm
      @asso = @tm.create_association("a_type")
      @topic = @tm.get!("a_topic")
    end
    after(:each) do
      @tm.close
    end
    
    describe "#reverse_players" do
      it "should give for each role the topic enactiong the association" do
        @topic.reverse_players.should be_empty
        a_asso = @tm.create_association("asso_type")
        a_asso.create_role("role_type",@topic)
        @topic.reverse_players.length.should == 1
        @topic.reverse_players.include?(a_asso).should be_true
        @topic.reverse_players("role_type").length.should == 1
        @topic.reverse_players("role_type").include?(a_asso).should be_true
        @topic.reverse_players("wrong_role_type").length.should == 0
        @topic.reverse_players("wrong_role_type").include?(a_asso).should be_false
      end
      it "should give back an empty set if the topic plays in no association" do
        @topic.reverse_players.should be_empty
      end
      it "should give back multiple entrys in the set if the topic plays multiple rols in one and the same association" do
        a_asso = @tm.create_association("asso_type")
        a_asso.create_role("role_type",@topic)
        @topic.reverse_players.size.should == 1
        a_asso.create_role("role_type_2",@topic)
        @topic.reverse_players.size.should == 2
      end
      it "should give back associations of the type specified in the optional item" do
        a_asso = @tm.create_association("asso_type")
        a_asso.create_role("role_type",@topic)
        @topic.reverse_players("wrong_role_type").size.should == 0
        @topic.reverse_players("role_type").size.should == 1
      end
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rtm-0.3.1 spec/rtm/navigation/topic/players_spec.rb
rtm-0.3.0 spec/rtm/navigation/topic/players_spec.rb
rtm-0.2.1 spec/rtm/navigation/topic/players_spec.rb
rtm-0.2.0 spec/rtm/navigation/topic/players_spec.rb
rtm-0.2 spec/rtm/navigation/topic/players_spec.rb