Class: Version::HelperTest
- Includes:
- ClientTester
- Defined in:
- lib/gems/xmpp4r-0.4/test/version/tc_helper.rb
Instance Method Summary collapse
Instance Method Details
#test_callback ⇒ Object
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 |
# File 'lib/gems/xmpp4r-0.4/test/version/tc_helper.rb', line 22 def test_callback # Prepare helper h = Version::Responder.new(@client) calls = 0 h.add_version_callback { |iq,responder| calls += 1 assert('jabber:iq:version', iq.queryns) responder.call('Test program', '1.0', 'Ruby Test::Unit') } # Send stanzas which shouldn't match @server.send("<iq type='set'><query xmlns='jabber:iq:version'/></iq>") @server.send("<iq type='get'><query xmlns='jabber:iq:browse'/></iq>") assert_equal(0, calls) # Send a query @server.send("<iq type='get'><query xmlns='jabber:iq:version'/></iq>") { |reply| assert_equal('Test program', reply.query.iname) assert_equal('1.0', reply.query.version) assert_equal('Ruby Test::Unit', reply.query.os) true } assert_equal(1, calls) end |
#test_create ⇒ Object
16 17 18 19 20 |
# File 'lib/gems/xmpp4r-0.4/test/version/tc_helper.rb', line 16 def test_create h = Version::Responder.new(@client) assert_kind_of(Version::Responder, h) assert_respond_to(h, :add_version_callback) end |
#test_simple ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gems/xmpp4r-0.4/test/version/tc_helper.rb', line 48 def test_simple h = Version::SimpleResponder.new(@client, 'Test program', '1.0', 'Ruby Test::Unit') # Send a query @server.send("<iq type='get'><query xmlns='jabber:iq:version'/></iq>") { |reply| assert_equal('Test program', reply.query.iname) assert_equal('1.0', reply.query.version) assert_equal('Ruby Test::Unit', reply.query.os) true } end |