Sha256: 273c2efd28260dc6fe2e7e0579c2f3b7500289e760d9fecdc61a3b948820bd56

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 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::Sugar
  module Association
    module HashAccess

      describe "#[]" do
        before(:each) do
          @tm = get_used_tm_sys_tm
          @assoc = @tm.create_association("assoc_type")
          @assoc2 = @tm.create_association("assoc_type2")
          @role1 = @assoc.create_role("role_type1", "player1")
          @role2 = @assoc.create_role("role_type2","player2")
          @role3 = @assoc2.create_role("role_type3","player3")
          @role4 = @assoc.create_role("role_type2","player4")
        end
        after(:each) do
          @tm.close
        end
        it "should give back Roles which have the specified Role type" do
          @assoc["role_type1"].size.should == 1
          @assoc["role_type1"].should include(@role1)
          @assoc["role_type2"].size.should == 2
          @assoc["role_type2"].should include(@role2)
          @assoc["role_type2"].should include(@role4)
        end
        it "should give back an empty Array if the type does not exist" do
          @assoc["wrong_type"].should == []
        end
        it "should give back all roles of the association if no type is given or type==:any" do
          @assoc[].size.should == 3
          @assoc[:any].size.should == 3
          @assoc[].should include(@role1)
          @assoc[].should include(@role2)
          @assoc[].should include(@role4)
          @assoc[:any].should include(@role1)
          @assoc[:any].should include(@role2)
          @assoc[:any].should include(@role4)
        end
      end
      describe "#[]=" do
        before(:each) do
          @tm = get_used_tm_sys_tm
        end
        after(:each) do
          @tm.close
        end
        it "should test []="
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rtm-0.3.1 spec/rtm/sugar/association/hash_access_spec.rb