Class: Roster::XRosterTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- Roster::XRosterTest
- Defined in:
- lib/vendor/xmpp4r/test/roster/tc_xroster.rb
Instance Method Summary collapse
- #test_actions ⇒ Object
- #test_create ⇒ Object
- #test_import ⇒ Object
- #test_items ⇒ Object
- #test_typed_add ⇒ Object
Instance Method Details
#test_actions ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/vendor/xmpp4r/test/roster/tc_xroster.rb', line 54 def test_actions j = Roster::XRosterItem.new assert_equal(:add, j.action) j.action = :modify assert_equal(:modify, j.action) j.action = :delete assert_equal(:delete, j.action) j.action = :invalid assert_equal(:add, j.action) j.attributes['action'] = 'modify' assert_equal(:modify, j.action) j.attributes['action'] = 'invalid' assert_equal(:add, j.action) end |
#test_create ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/vendor/xmpp4r/test/roster/tc_xroster.rb', line 12 def test_create r1 = Roster::XRoster.new assert_equal('x', r1.name) assert_equal('jabber:x:roster', r1.namespace) r2 = Roster::RosterX.new assert_equal('x', r2.name) assert_equal('http://jabber.org/protocol/rosterx', r2.namespace) end |
#test_import ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/vendor/xmpp4r/test/roster/tc_xroster.rb', line 21 def test_import x1 = X.new x1.add_namespace('jabber:x:roster') x2 = X::import(x1) assert_equal(Roster::XRoster, x2.class) assert_equal('jabber:x:roster', x2.namespace) end |
#test_items ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/vendor/xmpp4r/test/roster/tc_xroster.rb', line 37 def test_items j1 = Roster::XRosterItem.new assert_equal(JID.new(nil), j1.jid) assert_equal(nil, j1.iname) j2 = Roster::XRosterItem.new(JID.new('a@b/c')) assert_equal(JID.new('a@b/c'), j2.jid) assert_equal(nil, j2.iname) j3 = Roster::XRosterItem.new(JID.new('a@b/c'), 'Mr. Abc') assert_equal(JID.new('a@b/c'), j3.jid) assert_equal('Mr. Abc', j3.iname) assert_equal([], j3.groups) j3.groups = ['X', 'Y', 'Z'] assert_equal(['X', 'Y', 'Z'], j3.groups) end |
#test_typed_add ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/vendor/xmpp4r/test/roster/tc_xroster.rb', line 29 def test_typed_add x = REXML::Element.new('x') x.add(REXML::Element.new('item')) r = Roster::XRoster.new.import(x) assert_kind_of(Roster::XRosterItem, r.first_element('item')) assert_kind_of(Roster::XRosterItem, r.typed_add(REXML::Element.new('item'))) end |