Sha256: 677bc0b83a37ae44609d8ebcc19750dbd1bcd1169c3341af848c0a4ff972d367

Contents?: true

Size: 1.29 KB

Versions: 22

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

def ping_xml
<<-XML
<iq from='capulet.lit' to='juliet@capulet.lit/balcony' id='s2c1' type='get'>
  <ping xmlns='urn:xmpp:ping'/>
</iq>
XML
end

describe Blather::Stanza::Iq::Ping do
  it 'registers itself' do
    Blather::XMPPNode.class_from_registration(:ping, 'urn:xmpp:ping').should == Blather::Stanza::Iq::Ping
  end

  it 'can be imported' do
    node = Blather::XMPPNode.parse ping_xml
    node.should be_instance_of Blather::Stanza::Iq::Ping
  end

  it 'ensures a ping node is present on create' do
    iq = Blather::Stanza::Iq::Ping.new
    iq.xpath('ns:ping', :ns => 'urn:xmpp:ping').should_not be_empty
  end

  it 'ensures a ping node exists when calling #ping' do
    iq = Blather::Stanza::Iq::Ping.new
    iq.ping.remove
    iq.xpath('ns:ping', :ns => 'urn:xmpp:ping').should be_empty

    iq.ping.should_not be_nil
    iq.xpath('ns:ping', :ns => 'urn:xmpp:ping').should_not be_empty
  end

  it 'responds with an empty IQ' do
    ping = Blather::Stanza::Iq::Ping.new :get, 'one@example.com', 'abc123'
    ping.from = 'two@example.com'
    expected_pong = Blather::Stanza::Iq::Ping.new(:result, 'two@example.com', 'abc123').tap do |pong|
      pong.from = 'one@example.com'
    end
    reply = ping.reply
    reply.should == expected_pong
    reply.children.count.should == 0
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
blather-1.2.0 spec/blather/stanza/iq/ping_spec.rb
blather-1.1.4 spec/blather/stanza/iq/ping_spec.rb
blather-1.1.3 spec/blather/stanza/iq/ping_spec.rb
blather-1.1.2 spec/blather/stanza/iq/ping_spec.rb
blather-1.1.1 spec/blather/stanza/iq/ping_spec.rb
blather-1.1.0 spec/blather/stanza/iq/ping_spec.rb
blather-1.0.0 spec/blather/stanza/iq/ping_spec.rb
blather-0.8.8 spec/blather/stanza/iq/ping_spec.rb
blather-0.8.7 spec/blather/stanza/iq/ping_spec.rb
blather-0.8.6 spec/blather/stanza/iq/ping_spec.rb
blather-0.8.5 spec/blather/stanza/iq/ping_spec.rb
blather-0.8.4 spec/blather/stanza/iq/ping_spec.rb
blather-0.8.3 spec/blather/stanza/iq/ping_spec.rb
blather-0.8.2 spec/blather/stanza/iq/ping_spec.rb
tp-blather-0.8.5 spec/blather/stanza/iq/ping_spec.rb
tp-blather-0.8.4 spec/blather/stanza/iq/ping_spec.rb
tp-blather-0.8.3 spec/blather/stanza/iq/ping_spec.rb
tp-blather-0.8.2 spec/blather/stanza/iq/ping_spec.rb
blather-0.8.1 spec/blather/stanza/iq/ping_spec.rb
blather-0.8.0 spec/blather/stanza/iq/ping_spec.rb