Sha256: 5e979c14a861c944b4a101ee85321580e70465c1d77cce923d6842ccfc084bbf

Contents?: true

Size: 1.65 KB

Versions: 30

Compression:

Stored size: 1.65 KB

Contents

#!/usr/bin/ruby

$:.unshift File::dirname(__FILE__) + '/../../lib'

require 'test/unit'
require File::dirname(__FILE__) + '/../lib/clienttester'

require 'xmpp4r'
require 'xmpp4r/version/helper/responder'
require 'xmpp4r/version/helper/simpleresponder'
include Jabber

class Version::HelperTest < Test::Unit::TestCase
  include ClientTester

  def test_create
    h = Version::Responder.new(@client)
    assert_kind_of(Version::Responder, h)
    assert_respond_to(h, :add_version_callback)
  end

  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

  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
end

Version data entries

30 entries across 30 versions & 12 rubygems

Version Path
brontes3d-xmpp4r-0.4 test/version/tc_helper.rb
bryanl-xmpp4r-0.3.2 test/version/tc_helper.rb
edavey-xmpp4r-0.4.1 test/version/tc_helper.rb
edavey-xmpp4r-0.4.2 test/version/tc_helper.rb
edavey-xmpp4r-0.4 test/version/tc_helper.rb
heipei-xmpp4r-0.3.2 test/version/tc_helper.rb
ln-xmpp4r-0.5 test/version/tc_helper.rb
mojodna-xmpp4r-0.4.0.2 test/version/tc_helper.rb
mojodna-xmpp4r-0.4.0.3 test/version/tc_helper.rb
seanohalpin-xmpp4r-0.4.1 test/version/tc_helper.rb
xmpp4r-0.5.6 test/version/tc_helper.rb
xmpp4r-0.5.5 test/version/tc_helper.rb
mad-p-xmpp4r-0.6.3 test/version/tc_helper.rb
mad-p-xmpp4r-0.6.2 test/version/tc_helper.rb
mad-p-xmpp4r-0.6.1 test/version/tc_helper.rb
mad-p-xmpp4r-0.6.0 test/version/tc_helper.rb
cerberus-0.8.0 lib/vendor/xmpp4r/test/version/tc_helper.rb
cerberus-0.7.9 lib/vendor/xmpp4r/test/version/tc_helper.rb
edavis10-cerberus-0.7.8 lib/vendor/xmpp4r/test/version/tc_helper.rb
cerberus-0.7.8 lib/vendor/xmpp4r/test/version/tc_helper.rb