File: tc_mucowner.rb

package info (click to toggle)
ruby-xmpp4r 0.5.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,384 kB
  • sloc: ruby: 17,382; xml: 74; sh: 12; makefile: 4
file content (50 lines) | stat: -rwxr-xr-x 1,378 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
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
50
#!/usr/bin/ruby

$:.unshift '../lib'

require 'test/unit'
require 'xmpp4r'
require 'xmpp4r/muc'
include Jabber

class MUCOwnerTest < Test::Unit::TestCase
  def test_parse
    s = <<EOF
<iq from='darkcave@macbeth.shakespeare.lit'
    id='config1'
    to='crone1@shakespeare.lit/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
end