Class: MUCOwnerTest

Inherits:
Test::Unit::TestCase show all
Defined in:
lib/gems/xmpp4r-0.4/test/muc/tc_mucowner.rb

Instance Method Summary collapse

Methods inherited from Test::Unit::TestCase

#assert_array_equal, expect, #run

Instance Method Details

#test_parseObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/gems/xmpp4r-0.4/test/muc/tc_mucowner.rb', line 11

def test_parse
  s = <<EOF
<iq from='[email protected]'
  id='config1'
  to='[email protected]/desktop'
  type='result'>
<query xmlns='http://jabber.org/protocol/muc#owner'>
  <x xmlns='jabber:x:data' type='form'>
    <title>Configuration for "darkcave" Room</title>
    <instructions>
      Complete this form to make changes to
      the configuration of your room.
    </instructions>
    <field
        type='hidden'
        var='FORM_TYPE'>
      <value>http://jabber.org/protocol/muc#roomconfig</value>
    </field>
    <field
        label='Natural-Language Room Name'
        type='text-single'
        var='muc#roomconfig_roomname'>
      <value>A Dark Cave</value>
    </field>
  </x>
</query>
</iq>
EOF
  iq = Iq::import(REXML::Document.new(s).root)

  assert_kind_of(Iq, iq)
  assert_kind_of(MUC::IqQueryMUCOwner, iq.query)
  assert_kind_of(Dataforms::XData, iq.query.x)
  assert_kind_of(Dataforms::XData, iq.query.x('jabber:x:data'))
  assert_kind_of(Dataforms::XData, iq.query.x(Dataforms::XData))

  assert_equal(1, iq.query.x.fields.size)
  assert_equal('Natural-Language Room Name', iq.query.x.fields[0].label)
end