Sha256: 263c78c2d643365e1d48b57a35c0a921ced0a9572ca1f0985be06a3a048f1317

Contents?: true

Size: 1.43 KB

Versions: 15

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

def c_xml
  <<-XML
    <presence from='bard@shakespeare.lit/globe'>
      <c xmlns='http://jabber.org/protocol/caps'
         hash='sha-1'
         node='http://www.chatopus.com'
         ver='zHyEOgxTrkpSdGcQKH8EFPLsriY='/>
    </presence>
  XML
end

describe 'Blather::Stanza::Presence::C' do
  it 'registers itself' do
    Blather::XMPPNode.class_from_registration(:c, 'http://jabber.org/protocol/caps' ).must_equal Blather::Stanza::Presence::C
  end

  it 'must be importable' do
    c = Blather::XMPPNode.import(parse_stanza(c_xml).root).must_be_instance_of Blather::Stanza::Presence::C
  end

  it 'ensures hash is one of Blather::Stanza::Presence::C::VALID_HASH_TYPES' do
    lambda { Blather::Stanza::Presence::C.new nil, nil, :invalid_type_name }.must_raise(Blather::ArgumentError)

    Blather::Stanza::Presence::C::VALID_HASH_TYPES.each do |valid_hash|
      c = Blather::Stanza::Presence::C.new nil, nil, valid_hash
      c.hash.must_equal valid_hash.to_sym
    end
  end

  it 'can set a hash on creation' do
    c = Blather::Stanza::Presence::C.new nil, nil, :md5
    c.hash.must_equal :md5
  end

  it 'can set a node on creation' do
    c = Blather::Stanza::Presence::C.new 'http://www.chatopus.com'
    c.node.must_equal 'http://www.chatopus.com'
  end

  it 'can set a ver on creation' do
    c = Blather::Stanza::Presence::C.new nil, 'zHyEOgxTrkpSdGcQKH8EFPLsriY='
    c.ver.must_equal 'zHyEOgxTrkpSdGcQKH8EFPLsriY='
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
blather-0.6.2 spec/blather/stanza/presence/c_spec.rb
blather-0.6.1 spec/blather/stanza/presence/c_spec.rb
blather-0.6.0 spec/blather/stanza/presence/c_spec.rb
blather-0.5.12 spec/blather/stanza/presence/c_spec.rb
blather-0.5.11 spec/blather/stanza/presence/c_spec.rb
blather-0.5.10 spec/blather/stanza/presence/c_spec.rb
blather-0.5.9 spec/blather/stanza/presence/c_spec.rb
blather-0.5.8 spec/blather/stanza/presence/c_spec.rb
blather-0.5.7 spec/blather/stanza/presence/c_spec.rb
blather-0.5.6 spec/blather/stanza/presence/c_spec.rb
blather-0.5.4 spec/blather/stanza/presence/c_spec.rb
blather-0.5.3 spec/blather/stanza/presence/c_spec.rb
blather-0.5.2 spec/blather/stanza/presence/c_spec.rb
blather-0.5.0 spec/blather/stanza/presence/c_spec.rb
blather-0.4.16 spec/blather/stanza/presence/c_spec.rb