Method: MUCClientTest#test_nick

Defined in:
lib/vendor/xmpp4r/test/muc/tc_muc_mucclient.rb

#test_nickObject



541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
# File 'lib/vendor/xmpp4r/test/muc/tc_muc_mucclient.rb', line 541

def test_nick
  state { |pres|
    assert_kind_of(Presence, pres)
    assert_nil(pres.x.password)
    send("<presence from='[email protected]/thirdwitch' to='[email protected]/pda'>" +
         "<x xmlns='http://jabber.org/protocol/muc#user'><item affiliation='member' role='participant'/></x>" +
         "</presence>")
  }
  state { |pres|
    assert_kind_of(Presence, pres)
    assert_equal(JID.new('[email protected]/pda'), pres.from)
    assert_equal(JID.new('[email protected]/secondwitch'), pres.to)
    assert_nil(pres.type)
    send("<presence from='[email protected]' to='[email protected]/pda' type='error'>" +
         "<error code='409' type='cancel'><conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>" +
         "</presence>")
  }
  state { |pres|
    assert_kind_of(Presence, pres)
    assert_equal(JID.new('[email protected]/pda'), pres.from)
    assert_equal(JID.new('[email protected]/oldhag'), pres.to)
    assert_nil(pres.type)
    send("<presence from='[email protected]/thirdwitch' to='[email protected]/pda' type='unavailable'>" +
         "<x xmlns='http://jabber.org/protocol/muc#user'>" +
         "<item affiliation='member' jid='[email protected]/pda' nick='oldhag' role='participant'/>" +
         "<status code='303'/>" +
         "</x></presence>" +
         "<presence from='[email protected]/oldhag' to='[email protected]/pda'>" +
         "<x xmlns='http://jabber.org/protocol/muc#user'>" +
         "<item affiliation='member' jid='[email protected]/pda' role='participant'/>" +
         "</x></presence>")
  }

  m = MUC::MUCClient.new(@client)
  m.my_jid = '[email protected]/pda'

  assert_equal(m, m.join('[email protected]/thirdwitch'))
  wait_state
  assert(m.active?)
  assert_equal('thirdwitch', m.nick)

  assert_raises(ServerError) {
    m.nick = 'secondwitch'
  }
  wait_state
  assert(m.active?)
  assert_equal('thirdwitch', m.nick)

  m.nick = 'oldhag'
  wait_state
  assert(m.active?)
  assert_equal('oldhag', m.nick)
end