Sha256: fcc4b86a5e1f95142a9e9bc9f0e67aed6fd6f53b1d30e5ab29849526a7ab3ff7

Contents?: true

Size: 1.98 KB

Versions: 22

Compression:

Stored size: 1.98 KB

Contents

require 'spec_helper'
require 'fixtures/pubsub'

def control_affiliations
  { :owner => ['node1', 'node2'],
    :publisher => ['node3'],
    :outcast => ['node4'],
    :member => ['node5'],
    :none => ['node6'] }
end

describe Blather::Stanza::PubSub::Affiliations do
  it 'registers itself' do
    Blather::XMPPNode.class_from_registration(:affiliations, Blather::Stanza::PubSub.registered_ns).should == Blather::Stanza::PubSub::Affiliations
  end

  it 'can be imported' do
    Blather::XMPPNode.parse(affiliations_xml).should be_instance_of Blather::Stanza::PubSub::Affiliations
  end

  it 'ensures an affiliations node is present on create' do
    affiliations = Blather::Stanza::PubSub::Affiliations.new
    affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_nil
  end

  it 'ensures an affiliations node exists when calling #affiliations' do
    affiliations = Blather::Stanza::PubSub::Affiliations.new
    affiliations.pubsub.remove_children :affiliations
    affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).should be_nil

    affiliations.affiliations.should_not be_nil
    affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_nil
  end

  it 'defaults to a get node' do
    Blather::Stanza::PubSub::Affiliations.new.type.should == :get
  end

  it 'sets the host if requested' do
    aff = Blather::Stanza::PubSub::Affiliations.new :get, 'pubsub.jabber.local'
    aff.to.should == Blather::JID.new('pubsub.jabber.local')
  end

  it 'can import an affiliates result node' do
    node = parse_stanza(affiliations_xml).root

    affiliations = Blather::Stanza::PubSub::Affiliations.new.inherit node
    affiliations.size.should == 5
    affiliations.list.should == control_affiliations
  end

  it 'will iterate over each affiliation' do
    Blather::XMPPNode.parse(affiliations_xml).each do |type, nodes|
      nodes.should == control_affiliations[type]
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

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