Method: MUCClientTest#test_send

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

#test_sendObject



496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
# File 'lib/vendor/xmpp4r/test/muc/tc_muc_mucclient.rb', line 496

def test_send
  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 { |stanza|
    assert_kind_of(Message, stanza)
    assert(:groupchat, stanza.type)
    assert_equal(JID.new('[email protected]/pda'), stanza.from)
    assert_equal(JID.new('[email protected]'), stanza.to)
    assert_equal('First message', stanza.body)
  }
  state { |stanza|
    assert_kind_of(Message, stanza)
    assert(:chat, stanza.type)
    assert_equal(JID.new('[email protected]/pda'), stanza.from)
    assert_equal(JID.new('[email protected]/secondwitch'), stanza.to)
    assert_equal('Second message', stanza.body)
  }
  state { |stanza|
    assert_kind_of(Message, stanza)
    assert(:chat, stanza.type)
    assert_equal(JID.new('[email protected]/pda'), stanza.from)
    assert_equal(JID.new('[email protected]/firstwitch'), stanza.to)
    assert_equal('Third message', stanza.body)
  }

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

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

  m.send(Jabber::Message.new(nil, 'First message'))
  wait_state
  m.send(Jabber::Message.new(nil, 'Second message'), 'secondwitch')
  wait_state
  m.send(Jabber::Message.new('secondwitch', 'Third message'), 'firstwitch')
  wait_state
end