Sha256: 0324f8b417009a3907dfcd1ff1506bcdbd0d3b896edd823f51abbde154d37716

Contents?: true

Size: 1.91 KB

Versions: 2

Compression:

Stored size: 1.91 KB

Contents

require File.join(File.dirname(__FILE__), *%w[.. .. .. spec_helper])

describe 'Blather::Stanza::Presence::Subscription' do
  it 'registers itself' do
    XMPPNode.class_from_registration(:subscription, nil).must_equal Stanza::Presence::Subscription
  end

  it 'can set to on creation' do
    sub = Stanza::Presence::Subscription.new 'a@b'
    sub.to.to_s.must_equal 'a@b'
  end

  it 'can set a type on creation' do
    sub = Stanza::Presence::Subscription.new nil, :subscribed
    sub.type.must_equal :subscribed
  end

  it 'strips JIDs when setting #to' do
    sub = Stanza::Presence::Subscription.new 'a@b/c'
    sub.to.to_s.must_equal 'a@b'
  end

  it 'generates an approval using #approve!' do
    jid = JID.new 'a@b'
    sub = Stanza::Presence::Subscription.new
    sub.from = jid
    sub.approve!
    sub.to.must_equal jid
    sub.type.must_equal :subscribed
  end

  it 'generates a refusal using #refuse!' do
    jid = JID.new 'a@b'
    sub = Stanza::Presence::Subscription.new
    sub.from = jid
    sub.refuse!
    sub.to.must_equal jid
    sub.type.must_equal :unsubscribed
  end

  it 'generates an unsubscript using #unsubscribe!' do
    jid = JID.new 'a@b'
    sub = Stanza::Presence::Subscription.new
    sub.from = jid
    sub.unsubscribe!
    sub.to.must_equal jid
    sub.type.must_equal :unsubscribe
  end

  it 'generates a cancellation using #cancel!' do
    jid = JID.new 'a@b'
    sub = Stanza::Presence::Subscription.new
    sub.from = jid
    sub.cancel!
    sub.to.must_equal jid
    sub.type.must_equal :unsubscribed
  end

  it 'generates a request using #request!' do
    jid = JID.new 'a@b'
    sub = Stanza::Presence::Subscription.new
    sub.from = jid
    sub.request!
    sub.to.must_equal jid
    sub.type.must_equal :subscribe
  end

  it 'has a #request? helper' do
    sub = Stanza::Presence::Subscription.new
    sub.must_respond_to :request?
    sub.type = :subscribe
    sub.request?.must_equal true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blather-0.2.1 spec/blather/stanza/presence/subscription_spec.rb
blather-0.2 spec/blather/stanza/presence/subscription_spec.rb