Sha256: 2e79a4b0ff81185f75ba27f5b23173b07f2316d5250e531af5d252937593a98c

Contents?: true

Size: 1.49 KB

Versions: 22

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'

describe Blather::XMPPNode do
  before { @doc = Nokogiri::XML::Document.new }

  it 'generates a node based on the registered_name' do
    foo = Class.new(Blather::XMPPNode)
    foo.registered_name = 'foo'
    foo.new.element_name.should == 'foo'
  end

  it 'sets the namespace on creation' do
    foo = Class.new(Blather::XMPPNode)
    foo.registered_ns = 'foo'
    foo.new('foo').namespace.href.should == 'foo'
  end

  it 'registers sub classes' do
    class RegistersSubClass < Blather::XMPPNode; register 'foo', 'foo:bar'; end
    RegistersSubClass.registered_name.should == 'foo'
    RegistersSubClass.registered_ns.should == 'foo:bar'
    Blather::XMPPNode.class_from_registration('foo', 'foo:bar').should == RegistersSubClass
  end

  it 'imports another node' do
    class ImportSubClass < Blather::XMPPNode; register 'foo', 'foo:bar'; end
    n = Blather::XMPPNode.new('foo')
    n.namespace = 'foo:bar'
    Blather::XMPPNode.import(n).should be_kind_of ImportSubClass
  end

  it 'can convert itself into a stanza' do
    class StanzaConvert < Blather::XMPPNode; register 'foo'; end
    n = Blather::XMPPNode.new('foo')
    n.to_stanza.should be_kind_of StanzaConvert
  end

  it 'can parse a string and import it' do
    class StanzaParse < Blather::XMPPNode; register 'foo'; end
    string = '<foo/>'
    n = Nokogiri::XML(string).root
    i = Blather::XMPPNode.import n
    i.should be_kind_of StanzaParse
    p = Blather::XMPPNode.parse string
    p.should be_kind_of StanzaParse
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

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