blather 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +7 -5
- data/CHANGELOG +7 -0
- data/lib/blather.rb +1 -0
- data/lib/blather/stanza/message.rb +4 -0
- data/lib/blather/stanza/message/muc_user.rb +117 -0
- data/lib/blather/stanza/muc/muc_user_base.rb +53 -0
- data/lib/blather/stanza/presence/muc.rb +6 -0
- data/lib/blather/stanza/presence/muc_user.rb +14 -21
- data/lib/blather/version.rb +1 -1
- data/spec/blather/stanza/message/muc_user_spec.rb +152 -0
- data/spec/blather/stanza/message_spec.rb +1 -1
- data/spec/blather/stanza/presence/muc_spec.rb +3 -1
- data/spec/blather/stanza/presence/muc_user_spec.rb +25 -4
- metadata +34 -30
    
        data/.travis.yml
    CHANGED
    
    
    
        data/CHANGELOG
    CHANGED
    
    | @@ -1,5 +1,12 @@ | |
| 1 1 | 
             
            develop
         | 
| 2 2 |  | 
| 3 | 
            +
            v0.6.2
         | 
| 4 | 
            +
              Feature(benlangfeld): Add password support to MUCUser
         | 
| 5 | 
            +
              Feature(benlangfeld): Add support for invitation elements to MUCUser messages
         | 
| 6 | 
            +
              Feature(benlangfeld): Add support for MUC invite declines
         | 
| 7 | 
            +
              Bugfix(benlangfeld): Don't implicitly create an invite node when checking invite status
         | 
| 8 | 
            +
              Bugfix(benlangfeld): Ensure that form nodes are not duplicated on muc/muc_user presence stanzas
         | 
| 9 | 
            +
             | 
| 3 10 | 
             
            v0.6.1
         | 
| 4 11 | 
             
              Bugfix(benlangfeld): Ensure MUC presence nodes (joining) have a form element on creation
         | 
| 5 12 |  | 
    
        data/lib/blather.rb
    CHANGED
    
    
| @@ -180,6 +180,10 @@ class Stanza | |
| 180 180 | 
             
                    klass = class_from_registration(e.element_name, ns)
         | 
| 181 181 | 
             
                  end
         | 
| 182 182 |  | 
| 183 | 
            +
                  if klass == Blather::Stanza::Presence::MUCUser
         | 
| 184 | 
            +
                    klass = Blather::Stanza::Message::MUCUser
         | 
| 185 | 
            +
                  end
         | 
| 186 | 
            +
             | 
| 183 187 | 
             
                  if klass && klass != self && ![Blather::Stanza::X, Blather::Stanza::Iq].include?(klass)
         | 
| 184 188 | 
             
                    klass.import(node)
         | 
| 185 189 | 
             
                  else
         | 
| @@ -0,0 +1,117 @@ | |
| 1 | 
            +
            require 'blather/stanza/muc/muc_user_base'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Blather
         | 
| 4 | 
            +
            class Stanza
         | 
| 5 | 
            +
            class Message
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              class MUCUser < Message
         | 
| 8 | 
            +
                include Blather::Stanza::MUC::MUCUserBase
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                def self.new(to = nil, body = nil, type = :normal)
         | 
| 11 | 
            +
                  super
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def invite?
         | 
| 15 | 
            +
                  !!find_invite_node
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def invite_decline?
         | 
| 19 | 
            +
                  !!find_decline_node
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                def invite
         | 
| 23 | 
            +
                  if invite = find_invite_node
         | 
| 24 | 
            +
                    Invite.new invite
         | 
| 25 | 
            +
                  else
         | 
| 26 | 
            +
                    muc_user << (invite = Invite.new nil, nil, nil, self.document)
         | 
| 27 | 
            +
                    invite
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                def find_invite_node
         | 
| 32 | 
            +
                  muc_user.find_first 'ns:invite', :ns => self.class.registered_ns
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                def decline
         | 
| 36 | 
            +
                  if decline = find_decline_node
         | 
| 37 | 
            +
                    Decline.new decline
         | 
| 38 | 
            +
                  else
         | 
| 39 | 
            +
                    muc_user << (decline = Decline.new nil, nil, nil, self.document)
         | 
| 40 | 
            +
                    decline
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                def find_decline_node
         | 
| 45 | 
            +
                  muc_user.find_first 'ns:decline', :ns => self.class.registered_ns
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                class InviteBase < XMPPNode
         | 
| 49 | 
            +
                  def self.new(element_name, to = nil, from = nil, reason = nil, document = nil)
         | 
| 50 | 
            +
                    new_node = super element_name, document
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                    case to
         | 
| 53 | 
            +
                    when self
         | 
| 54 | 
            +
                      to.document ||= document
         | 
| 55 | 
            +
                      return to
         | 
| 56 | 
            +
                    when Nokogiri::XML::Node
         | 
| 57 | 
            +
                      new_node.inherit to
         | 
| 58 | 
            +
                    when Hash
         | 
| 59 | 
            +
                      new_node.to = to[:to]
         | 
| 60 | 
            +
                      new_node.from = to[:from]
         | 
| 61 | 
            +
                      new_node.reason = to[:reason]
         | 
| 62 | 
            +
                    else
         | 
| 63 | 
            +
                      new_node.to = to
         | 
| 64 | 
            +
                      new_node.from = from
         | 
| 65 | 
            +
                      new_node.reason = reason
         | 
| 66 | 
            +
                    end
         | 
| 67 | 
            +
                    new_node
         | 
| 68 | 
            +
                  end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  def to
         | 
| 71 | 
            +
                    read_attr :to
         | 
| 72 | 
            +
                  end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                  def to=(val)
         | 
| 75 | 
            +
                    write_attr :to, val
         | 
| 76 | 
            +
                  end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                  def from
         | 
| 79 | 
            +
                    read_attr :from
         | 
| 80 | 
            +
                  end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                  def from=(val)
         | 
| 83 | 
            +
                    write_attr :from, val
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                  def reason
         | 
| 87 | 
            +
                    reason_node.content.strip
         | 
| 88 | 
            +
                  end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                  def reason=(val)
         | 
| 91 | 
            +
                    reason_node.content = val
         | 
| 92 | 
            +
                  end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                  def reason_node
         | 
| 95 | 
            +
                    unless reason = find_first('ns:reason', :ns => MUCUser.registered_ns)
         | 
| 96 | 
            +
                      self << (reason = XMPPNode.new('reason', self.document))
         | 
| 97 | 
            +
                    end
         | 
| 98 | 
            +
                    reason
         | 
| 99 | 
            +
                  end
         | 
| 100 | 
            +
                end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                class Invite < InviteBase
         | 
| 103 | 
            +
                  def self.new(*args)
         | 
| 104 | 
            +
                    new_node = super :invite, *args
         | 
| 105 | 
            +
                  end
         | 
| 106 | 
            +
                end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                class Decline < InviteBase
         | 
| 109 | 
            +
                  def self.new(*args)
         | 
| 110 | 
            +
                    new_node = super :decline, *args
         | 
| 111 | 
            +
                  end
         | 
| 112 | 
            +
                end
         | 
| 113 | 
            +
              end # MUC
         | 
| 114 | 
            +
             | 
| 115 | 
            +
            end # Presence
         | 
| 116 | 
            +
            end # Stanza
         | 
| 117 | 
            +
            end # Blather
         | 
| @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            module Blather
         | 
| 2 | 
            +
            class Stanza
         | 
| 3 | 
            +
            class MUC
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              module MUCUserBase
         | 
| 6 | 
            +
                def self.included(klass)
         | 
| 7 | 
            +
                  klass.extend ClassMethods
         | 
| 8 | 
            +
                  klass.register :muc_user, :x, "http://jabber.org/protocol/muc#user"
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                module ClassMethods
         | 
| 12 | 
            +
                  def new(*args)
         | 
| 13 | 
            +
                    super.tap { |e| e.muc_user }
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                def inherit(node)
         | 
| 18 | 
            +
                  muc_user.remove
         | 
| 19 | 
            +
                  super
         | 
| 20 | 
            +
                  self
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def password
         | 
| 24 | 
            +
                  find_password_node && password_node.content
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                def password=(var)
         | 
| 28 | 
            +
                  password_node.content = var
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                def muc_user
         | 
| 32 | 
            +
                  unless muc_user = find_first('ns:x', :ns => self.class.registered_ns)
         | 
| 33 | 
            +
                    self << (muc_user = XMPPNode.new('x', self.document))
         | 
| 34 | 
            +
                    muc_user.namespace = self.class.registered_ns
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
                  muc_user
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def password_node
         | 
| 40 | 
            +
                  unless pw = find_password_node
         | 
| 41 | 
            +
                    muc_user << (pw = XMPPNode.new('password', self.document))
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                  pw
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                def find_password_node
         | 
| 47 | 
            +
                  muc_user.find_first 'ns:password', :ns => self.class.registered_ns
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
              end # MUCUserBase
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            end # MUC
         | 
| 52 | 
            +
            end # Stanza
         | 
| 53 | 
            +
            end # Blather
         | 
| @@ -1,9 +1,11 @@ | |
| 1 | 
            +
            require 'blather/stanza/muc/muc_user_base'
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module Blather
         | 
| 2 4 | 
             
            class Stanza
         | 
| 3 5 | 
             
            class Presence
         | 
| 4 6 |  | 
| 5 7 | 
             
              class MUCUser < Status
         | 
| 6 | 
            -
                 | 
| 8 | 
            +
                include Blather::Stanza::MUC::MUCUserBase
         | 
| 7 9 |  | 
| 8 10 | 
             
                def affiliation
         | 
| 9 11 | 
             
                  item.affiliation
         | 
| @@ -40,29 +42,20 @@ class Presence | |
| 40 42 | 
             
                  end
         | 
| 41 43 | 
             
                end
         | 
| 42 44 |  | 
| 43 | 
            -
                 | 
| 44 | 
            -
                   | 
| 45 | 
            -
                     | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
                     | 
| 49 | 
            -
                    muc_user
         | 
| 50 | 
            -
                  end
         | 
| 51 | 
            -
             | 
| 52 | 
            -
                  def item
         | 
| 53 | 
            -
                    if item = muc_user.find_first('ns:item', :ns => self.class.registered_ns)
         | 
| 54 | 
            -
                      Item.new item
         | 
| 55 | 
            -
                    else
         | 
| 56 | 
            -
                      muc_user << (item = Item.new nil, nil, nil, self.document)
         | 
| 57 | 
            -
                      item
         | 
| 58 | 
            -
                    end
         | 
| 45 | 
            +
                def item
         | 
| 46 | 
            +
                  if item = muc_user.find_first('ns:item', :ns => self.class.registered_ns)
         | 
| 47 | 
            +
                    Item.new item
         | 
| 48 | 
            +
                  else
         | 
| 49 | 
            +
                    muc_user << (item = Item.new nil, nil, nil, self.document)
         | 
| 50 | 
            +
                    item
         | 
| 59 51 | 
             
                  end
         | 
| 52 | 
            +
                end
         | 
| 60 53 |  | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
                    end
         | 
| 54 | 
            +
                def status
         | 
| 55 | 
            +
                  muc_user.find('ns:status', :ns => self.class.registered_ns).map do |status|
         | 
| 56 | 
            +
                    Status.new status
         | 
| 65 57 | 
             
                  end
         | 
| 58 | 
            +
                end
         | 
| 66 59 |  | 
| 67 60 | 
             
                class Item < XMPPNode
         | 
| 68 61 | 
             
                  def self.new(affiliation = nil, role = nil, jid = nil, document = nil)
         | 
    
        data/lib/blather/version.rb
    CHANGED
    
    
| @@ -0,0 +1,152 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            def muc_invite_xml
         | 
| 4 | 
            +
              <<-XML
         | 
| 5 | 
            +
              <message
         | 
| 6 | 
            +
                    from='coven@chat.shakespeare.lit'
         | 
| 7 | 
            +
                    id='nzd143v8'
         | 
| 8 | 
            +
                    to='hecate@shakespeare.lit'>
         | 
| 9 | 
            +
                  <x xmlns='http://jabber.org/protocol/muc#user'>
         | 
| 10 | 
            +
                    <invite to='hecate@shakespeare.lit' from='crone1@shakespeare.lit/desktop'>
         | 
| 11 | 
            +
                      <reason>
         | 
| 12 | 
            +
                        Hey Hecate, this is the place for all good witches!
         | 
| 13 | 
            +
                      </reason>
         | 
| 14 | 
            +
                    </invite>
         | 
| 15 | 
            +
                    <password>foobar</password>
         | 
| 16 | 
            +
                  </x>
         | 
| 17 | 
            +
                </message>
         | 
| 18 | 
            +
              XML
         | 
| 19 | 
            +
            end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            def muc_decline_xml
         | 
| 22 | 
            +
              <<-XML
         | 
| 23 | 
            +
                <message
         | 
| 24 | 
            +
                    from='hecate@shakespeare.lit/broom'
         | 
| 25 | 
            +
                    id='jk2vs61v'
         | 
| 26 | 
            +
                    to='coven@chat.shakespeare.lit'>
         | 
| 27 | 
            +
                  <x xmlns='http://jabber.org/protocol/muc#user'>
         | 
| 28 | 
            +
                    <decline to='crone1@shakespeare.lit' from='hecate@shakespeare.lit'>
         | 
| 29 | 
            +
                      <reason>
         | 
| 30 | 
            +
                        Sorry, I'm too busy right now.
         | 
| 31 | 
            +
                      </reason>
         | 
| 32 | 
            +
                    </decline>
         | 
| 33 | 
            +
                  </x>
         | 
| 34 | 
            +
                </message>
         | 
| 35 | 
            +
              XML
         | 
| 36 | 
            +
            end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            describe 'Blather::Stanza::Message::MUCUser' do
         | 
| 39 | 
            +
              it 'ensures a form node is present on create' do
         | 
| 40 | 
            +
                c = Blather::Stanza::Message::MUCUser.new
         | 
| 41 | 
            +
                c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).wont_be_empty
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              it 'ensures a form node exists when calling #muc' do
         | 
| 45 | 
            +
                c = Blather::Stanza::Message::MUCUser.new
         | 
| 46 | 
            +
                c.remove_children :x
         | 
| 47 | 
            +
                c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).must_be_empty
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                c.muc_user.wont_be_nil
         | 
| 50 | 
            +
                c.xpath('ns:x', :ns => Blather::Stanza::Message::MUCUser.registered_ns).wont_be_empty
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
              it 'ensures the message type is :normal' do
         | 
| 54 | 
            +
                m = Blather::Stanza::Message::MUCUser.new
         | 
| 55 | 
            +
                m.normal?.must_equal true
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              it "must be able to set the password" do
         | 
| 59 | 
            +
                muc_user = Blather::Stanza::Message::MUCUser.new
         | 
| 60 | 
            +
                muc_user.password.must_equal nil
         | 
| 61 | 
            +
                muc_user.password = 'barbaz'
         | 
| 62 | 
            +
                muc_user.password.must_equal 'barbaz'
         | 
| 63 | 
            +
                muc_user.password = 'hello_world'
         | 
| 64 | 
            +
                muc_user.password.must_equal 'hello_world'
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
              it "should not be an #invite?" do
         | 
| 68 | 
            +
                muc_user = Blather::Stanza::Message::MUCUser.new
         | 
| 69 | 
            +
                muc_user.invite?.must_equal false
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              describe "with an invite element" do
         | 
| 73 | 
            +
                it "should be an #invite?" do
         | 
| 74 | 
            +
                  muc_user = Blather::XMPPNode.import(parse_stanza(muc_invite_xml).root)
         | 
| 75 | 
            +
                  muc_user.invite?.must_equal true
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                it "should know the invite attributes properly" do
         | 
| 79 | 
            +
                  muc_user = Blather::XMPPNode.import(parse_stanza(muc_invite_xml).root)
         | 
| 80 | 
            +
                  muc_user.must_be_instance_of Blather::Stanza::Message::MUCUser
         | 
| 81 | 
            +
                  invite = muc_user.invite
         | 
| 82 | 
            +
                  invite.to.must_equal 'hecate@shakespeare.lit'
         | 
| 83 | 
            +
                  invite.from.must_equal 'crone1@shakespeare.lit/desktop'
         | 
| 84 | 
            +
                  invite.reason.must_equal 'Hey Hecate, this is the place for all good witches!'
         | 
| 85 | 
            +
                  muc_user.password.must_equal 'foobar'
         | 
| 86 | 
            +
                end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                it "must be able to set the to jid" do
         | 
| 89 | 
            +
                  muc_user = Blather::Stanza::Message::MUCUser.new
         | 
| 90 | 
            +
                  invite = muc_user.invite
         | 
| 91 | 
            +
                  invite.to.must_equal nil
         | 
| 92 | 
            +
                  invite.to = 'foo@bar.com'
         | 
| 93 | 
            +
                  invite.to.must_equal 'foo@bar.com'
         | 
| 94 | 
            +
                end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                it "must be able to set the from jid" do
         | 
| 97 | 
            +
                  muc_user = Blather::Stanza::Message::MUCUser.new
         | 
| 98 | 
            +
                  invite = muc_user.invite
         | 
| 99 | 
            +
                  invite.from.must_equal nil
         | 
| 100 | 
            +
                  invite.from = 'foo@bar.com'
         | 
| 101 | 
            +
                  invite.from.must_equal 'foo@bar.com'
         | 
| 102 | 
            +
                end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                it "must be able to set the reason" do
         | 
| 105 | 
            +
                  muc_user = Blather::Stanza::Message::MUCUser.new
         | 
| 106 | 
            +
                  invite = muc_user.invite
         | 
| 107 | 
            +
                  invite.reason.must_equal ''
         | 
| 108 | 
            +
                  invite.reason = 'Please join'
         | 
| 109 | 
            +
                  invite.reason.must_equal 'Please join'
         | 
| 110 | 
            +
                end
         | 
| 111 | 
            +
              end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
              describe "with a decline element" do
         | 
| 114 | 
            +
                it "should be an #invite_decline?" do
         | 
| 115 | 
            +
                  muc_user = Blather::XMPPNode.import(parse_stanza(muc_decline_xml).root)
         | 
| 116 | 
            +
                  muc_user.must_be_instance_of Blather::Stanza::Message::MUCUser
         | 
| 117 | 
            +
                  muc_user.invite_decline?.must_equal true
         | 
| 118 | 
            +
                end
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                it "should know the decline attributes properly" do
         | 
| 121 | 
            +
                  muc_user = Blather::XMPPNode.import(parse_stanza(muc_decline_xml).root)
         | 
| 122 | 
            +
                  decline = muc_user.decline
         | 
| 123 | 
            +
                  decline.to.must_equal 'crone1@shakespeare.lit'
         | 
| 124 | 
            +
                  decline.from.must_equal 'hecate@shakespeare.lit'
         | 
| 125 | 
            +
                  decline.reason.must_equal "Sorry, I'm too busy right now."
         | 
| 126 | 
            +
                end
         | 
| 127 | 
            +
             | 
| 128 | 
            +
                it "must be able to set the to jid" do
         | 
| 129 | 
            +
                  muc_user = Blather::Stanza::Message::MUCUser.new
         | 
| 130 | 
            +
                  decline = muc_user.decline
         | 
| 131 | 
            +
                  decline.to.must_equal nil
         | 
| 132 | 
            +
                  decline.to = 'foo@bar.com'
         | 
| 133 | 
            +
                  decline.to.must_equal 'foo@bar.com'
         | 
| 134 | 
            +
                end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                it "must be able to set the from jid" do
         | 
| 137 | 
            +
                  muc_user = Blather::Stanza::Message::MUCUser.new
         | 
| 138 | 
            +
                  decline = muc_user.decline
         | 
| 139 | 
            +
                  decline.from.must_equal nil
         | 
| 140 | 
            +
                  decline.from = 'foo@bar.com'
         | 
| 141 | 
            +
                  decline.from.must_equal 'foo@bar.com'
         | 
| 142 | 
            +
                end
         | 
| 143 | 
            +
             | 
| 144 | 
            +
                it "must be able to set the reason" do
         | 
| 145 | 
            +
                  muc_user = Blather::Stanza::Message::MUCUser.new
         | 
| 146 | 
            +
                  decline = muc_user.decline
         | 
| 147 | 
            +
                  decline.reason.must_equal ''
         | 
| 148 | 
            +
                  decline.reason = 'Please join'
         | 
| 149 | 
            +
                  decline.reason.must_equal 'Please join'
         | 
| 150 | 
            +
                end
         | 
| 151 | 
            +
              end
         | 
| 152 | 
            +
            end
         | 
| @@ -275,7 +275,7 @@ describe Blather::Stanza::Message do | |
| 275 275 | 
             
                  n.delayed?.must_equal true
         | 
| 276 276 | 
             
                  n.delay.must_be_instance_of Blather::Stanza::Message::Delay
         | 
| 277 277 | 
             
                  n.delay.from.must_equal 'coven@chat.shakespeare.lit'
         | 
| 278 | 
            -
                  n.delay.stamp.must_equal Time. | 
| 278 | 
            +
                  n.delay.stamp.must_equal Time.utc(2002, 10, 13, 23, 58, 37, 0)
         | 
| 279 279 | 
             
                  n.delay.description.must_equal "Too slow"
         | 
| 280 280 | 
             
                end
         | 
| 281 281 | 
             
              end
         | 
| @@ -16,7 +16,9 @@ describe 'Blather::Stanza::Presence::MUC' do | |
| 16 16 | 
             
              end
         | 
| 17 17 |  | 
| 18 18 | 
             
              it 'must be importable' do
         | 
| 19 | 
            -
                c = Blather::XMPPNode.import(parse_stanza(muc_xml).root) | 
| 19 | 
            +
                c = Blather::XMPPNode.import(parse_stanza(muc_xml).root)
         | 
| 20 | 
            +
                c.must_be_instance_of Blather::Stanza::Presence::MUC
         | 
| 21 | 
            +
                c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUC.registered_ns).count.must_equal 1
         | 
| 20 22 | 
             
              end
         | 
| 21 23 |  | 
| 22 24 | 
             
              it 'ensures a form node is present on create' do
         | 
| @@ -11,16 +11,13 @@ def muc_user_xml | |
| 11 11 | 
             
                          role='participant'/>
         | 
| 12 12 | 
             
                    <status code='100'/>
         | 
| 13 13 | 
             
                    <status code='110'/>
         | 
| 14 | 
            +
                    <password>foobar</password>
         | 
| 14 15 | 
             
                  </x>
         | 
| 15 16 | 
             
                </presence>
         | 
| 16 17 | 
             
              XML
         | 
| 17 18 | 
             
            end
         | 
| 18 19 |  | 
| 19 20 | 
             
            describe 'Blather::Stanza::Presence::MUCUser' do
         | 
| 20 | 
            -
              it 'registers itself' do
         | 
| 21 | 
            -
                Blather::XMPPNode.class_from_registration(:x, 'http://jabber.org/protocol/muc#user' ).must_equal Blather::Stanza::Presence::MUCUser
         | 
| 22 | 
            -
              end
         | 
| 23 | 
            -
             | 
| 24 21 | 
             
              it 'must be importable' do
         | 
| 25 22 | 
             
                muc_user = Blather::XMPPNode.import(parse_stanza(muc_user_xml).root)
         | 
| 26 23 | 
             
                muc_user.must_be_instance_of Blather::Stanza::Presence::MUCUser
         | 
| @@ -28,6 +25,21 @@ describe 'Blather::Stanza::Presence::MUCUser' do | |
| 28 25 | 
             
                muc_user.jid.must_equal 'hag66@shakespeare.lit/pda'
         | 
| 29 26 | 
             
                muc_user.role.must_equal :participant
         | 
| 30 27 | 
             
                muc_user.status_codes.must_equal [100, 110]
         | 
| 28 | 
            +
                muc_user.password.must_equal 'foobar'
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              it 'ensures a form node is present on create' do
         | 
| 32 | 
            +
                c = Blather::Stanza::Presence::MUCUser.new
         | 
| 33 | 
            +
                c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUCUser.registered_ns).wont_be_empty
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              it 'ensures a form node exists when calling #muc' do
         | 
| 37 | 
            +
                c = Blather::Stanza::Presence::MUCUser.new
         | 
| 38 | 
            +
                c.remove_children :x
         | 
| 39 | 
            +
                c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUCUser.registered_ns).must_be_empty
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                c.muc_user.wont_be_nil
         | 
| 42 | 
            +
                c.xpath('ns:x', :ns => Blather::Stanza::Presence::MUCUser.registered_ns).wont_be_empty
         | 
| 31 43 | 
             
              end
         | 
| 32 44 |  | 
| 33 45 | 
             
              it "must be able to set the affiliation" do
         | 
| @@ -59,4 +71,13 @@ describe 'Blather::Stanza::Presence::MUCUser' do | |
| 59 71 | 
             
                muc_user.status_codes = [500]
         | 
| 60 72 | 
             
                muc_user.status_codes.must_equal [500]
         | 
| 61 73 | 
             
              end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
              it "must be able to set the password" do
         | 
| 76 | 
            +
                muc_user = Blather::Stanza::Presence::MUCUser.new
         | 
| 77 | 
            +
                muc_user.password.must_equal nil
         | 
| 78 | 
            +
                muc_user.password = 'barbaz'
         | 
| 79 | 
            +
                muc_user.password.must_equal 'barbaz'
         | 
| 80 | 
            +
                muc_user.password = 'hello_world'
         | 
| 81 | 
            +
                muc_user.password.must_equal 'hello_world'
         | 
| 82 | 
            +
              end
         | 
| 62 83 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: blather
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.6. | 
| 4 | 
            +
              version: 0.6.2
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,11 +9,11 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2012-02- | 
| 12 | 
            +
            date: 2012-02-28 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: eventmachine
         | 
| 16 | 
            -
              requirement: & | 
| 16 | 
            +
              requirement: &2156245180 !ruby/object:Gem::Requirement
         | 
| 17 17 | 
             
                none: false
         | 
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ! '>='
         | 
| @@ -21,10 +21,10 @@ dependencies: | |
| 21 21 | 
             
                    version: 0.12.6
         | 
| 22 22 | 
             
              type: :runtime
         | 
| 23 23 | 
             
              prerelease: false
         | 
| 24 | 
            -
              version_requirements: * | 
| 24 | 
            +
              version_requirements: *2156245180
         | 
| 25 25 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 26 26 | 
             
              name: nokogiri
         | 
| 27 | 
            -
              requirement: & | 
| 27 | 
            +
              requirement: &2156244500 !ruby/object:Gem::Requirement
         | 
| 28 28 | 
             
                none: false
         | 
| 29 29 | 
             
                requirements:
         | 
| 30 30 | 
             
                - - ~>
         | 
| @@ -32,10 +32,10 @@ dependencies: | |
| 32 32 | 
             
                    version: 1.4.0
         | 
| 33 33 | 
             
              type: :runtime
         | 
| 34 34 | 
             
              prerelease: false
         | 
| 35 | 
            -
              version_requirements: * | 
| 35 | 
            +
              version_requirements: *2156244500
         | 
| 36 36 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 37 37 | 
             
              name: niceogiri
         | 
| 38 | 
            -
              requirement: & | 
| 38 | 
            +
              requirement: &2156243540 !ruby/object:Gem::Requirement
         | 
| 39 39 | 
             
                none: false
         | 
| 40 40 | 
             
                requirements:
         | 
| 41 41 | 
             
                - - ! '>='
         | 
| @@ -43,10 +43,10 @@ dependencies: | |
| 43 43 | 
             
                    version: 0.1.0
         | 
| 44 44 | 
             
              type: :runtime
         | 
| 45 45 | 
             
              prerelease: false
         | 
| 46 | 
            -
              version_requirements: * | 
| 46 | 
            +
              version_requirements: *2156243540
         | 
| 47 47 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 48 48 | 
             
              name: activesupport
         | 
| 49 | 
            -
              requirement: & | 
| 49 | 
            +
              requirement: &2156242620 !ruby/object:Gem::Requirement
         | 
| 50 50 | 
             
                none: false
         | 
| 51 51 | 
             
                requirements:
         | 
| 52 52 | 
             
                - - ! '>='
         | 
| @@ -54,10 +54,10 @@ dependencies: | |
| 54 54 | 
             
                    version: 3.0.7
         | 
| 55 55 | 
             
              type: :runtime
         | 
| 56 56 | 
             
              prerelease: false
         | 
| 57 | 
            -
              version_requirements: * | 
| 57 | 
            +
              version_requirements: *2156242620
         | 
| 58 58 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 59 59 | 
             
              name: minitest
         | 
| 60 | 
            -
              requirement: & | 
| 60 | 
            +
              requirement: &2156241660 !ruby/object:Gem::Requirement
         | 
| 61 61 | 
             
                none: false
         | 
| 62 62 | 
             
                requirements:
         | 
| 63 63 | 
             
                - - ~>
         | 
| @@ -65,10 +65,10 @@ dependencies: | |
| 65 65 | 
             
                    version: 1.7.1
         | 
| 66 66 | 
             
              type: :development
         | 
| 67 67 | 
             
              prerelease: false
         | 
| 68 | 
            -
              version_requirements: * | 
| 68 | 
            +
              version_requirements: *2156241660
         | 
| 69 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 70 | 
             
              name: mocha
         | 
| 71 | 
            -
              requirement: & | 
| 71 | 
            +
              requirement: &2156240420 !ruby/object:Gem::Requirement
         | 
| 72 72 | 
             
                none: false
         | 
| 73 73 | 
             
                requirements:
         | 
| 74 74 | 
             
                - - ~>
         | 
| @@ -76,10 +76,10 @@ dependencies: | |
| 76 76 | 
             
                    version: 0.9.12
         | 
| 77 77 | 
             
              type: :development
         | 
| 78 78 | 
             
              prerelease: false
         | 
| 79 | 
            -
              version_requirements: * | 
| 79 | 
            +
              version_requirements: *2156240420
         | 
| 80 80 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 81 81 | 
             
              name: bundler
         | 
| 82 | 
            -
              requirement: & | 
| 82 | 
            +
              requirement: &2156239840 !ruby/object:Gem::Requirement
         | 
| 83 83 | 
             
                none: false
         | 
| 84 84 | 
             
                requirements:
         | 
| 85 85 | 
             
                - - ~>
         | 
| @@ -87,10 +87,10 @@ dependencies: | |
| 87 87 | 
             
                    version: 1.0.0
         | 
| 88 88 | 
             
              type: :development
         | 
| 89 89 | 
             
              prerelease: false
         | 
| 90 | 
            -
              version_requirements: * | 
| 90 | 
            +
              version_requirements: *2156239840
         | 
| 91 91 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 92 92 | 
             
              name: rcov
         | 
| 93 | 
            -
              requirement: & | 
| 93 | 
            +
              requirement: &2156238560 !ruby/object:Gem::Requirement
         | 
| 94 94 | 
             
                none: false
         | 
| 95 95 | 
             
                requirements:
         | 
| 96 96 | 
             
                - - ~>
         | 
| @@ -98,10 +98,10 @@ dependencies: | |
| 98 98 | 
             
                    version: 0.9.9
         | 
| 99 99 | 
             
              type: :development
         | 
| 100 100 | 
             
              prerelease: false
         | 
| 101 | 
            -
              version_requirements: * | 
| 101 | 
            +
              version_requirements: *2156238560
         | 
| 102 102 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 103 103 | 
             
              name: yard
         | 
| 104 | 
            -
              requirement: & | 
| 104 | 
            +
              requirement: &2156237900 !ruby/object:Gem::Requirement
         | 
| 105 105 | 
             
                none: false
         | 
| 106 106 | 
             
                requirements:
         | 
| 107 107 | 
             
                - - ~>
         | 
| @@ -109,10 +109,10 @@ dependencies: | |
| 109 109 | 
             
                    version: 0.6.1
         | 
| 110 110 | 
             
              type: :development
         | 
| 111 111 | 
             
              prerelease: false
         | 
| 112 | 
            -
              version_requirements: * | 
| 112 | 
            +
              version_requirements: *2156237900
         | 
| 113 113 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 114 114 | 
             
              name: rake
         | 
| 115 | 
            -
              requirement: & | 
| 115 | 
            +
              requirement: &2156237420 !ruby/object:Gem::Requirement
         | 
| 116 116 | 
             
                none: false
         | 
| 117 117 | 
             
                requirements:
         | 
| 118 118 | 
             
                - - ! '>='
         | 
| @@ -120,10 +120,10 @@ dependencies: | |
| 120 120 | 
             
                    version: '0'
         | 
| 121 121 | 
             
              type: :development
         | 
| 122 122 | 
             
              prerelease: false
         | 
| 123 | 
            -
              version_requirements: * | 
| 123 | 
            +
              version_requirements: *2156237420
         | 
| 124 124 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 125 125 | 
             
              name: guard-minitest
         | 
| 126 | 
            -
              requirement: & | 
| 126 | 
            +
              requirement: &2156236560 !ruby/object:Gem::Requirement
         | 
| 127 127 | 
             
                none: false
         | 
| 128 128 | 
             
                requirements:
         | 
| 129 129 | 
             
                - - ! '>='
         | 
| @@ -131,10 +131,10 @@ dependencies: | |
| 131 131 | 
             
                    version: '0'
         | 
| 132 132 | 
             
              type: :development
         | 
| 133 133 | 
             
              prerelease: false
         | 
| 134 | 
            -
              version_requirements: * | 
| 134 | 
            +
              version_requirements: *2156236560
         | 
| 135 135 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 136 136 | 
             
              name: bluecloth
         | 
| 137 | 
            -
              requirement: & | 
| 137 | 
            +
              requirement: &2156235340 !ruby/object:Gem::Requirement
         | 
| 138 138 | 
             
                none: false
         | 
| 139 139 | 
             
                requirements:
         | 
| 140 140 | 
             
                - - ! '>='
         | 
| @@ -142,10 +142,10 @@ dependencies: | |
| 142 142 | 
             
                    version: '0'
         | 
| 143 143 | 
             
              type: :development
         | 
| 144 144 | 
             
              prerelease: false
         | 
| 145 | 
            -
              version_requirements: * | 
| 145 | 
            +
              version_requirements: *2156235340
         | 
| 146 146 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 147 147 | 
             
              name: growl_notify
         | 
| 148 | 
            -
              requirement: & | 
| 148 | 
            +
              requirement: &2156233800 !ruby/object:Gem::Requirement
         | 
| 149 149 | 
             
                none: false
         | 
| 150 150 | 
             
                requirements:
         | 
| 151 151 | 
             
                - - ! '>='
         | 
| @@ -153,10 +153,10 @@ dependencies: | |
| 153 153 | 
             
                    version: '0'
         | 
| 154 154 | 
             
              type: :development
         | 
| 155 155 | 
             
              prerelease: false
         | 
| 156 | 
            -
              version_requirements: * | 
| 156 | 
            +
              version_requirements: *2156233800
         | 
| 157 157 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 158 158 | 
             
              name: rb-fsevent
         | 
| 159 | 
            -
              requirement: & | 
| 159 | 
            +
              requirement: &2156232440 !ruby/object:Gem::Requirement
         | 
| 160 160 | 
             
                none: false
         | 
| 161 161 | 
             
                requirements:
         | 
| 162 162 | 
             
                - - ! '>='
         | 
| @@ -164,7 +164,7 @@ dependencies: | |
| 164 164 | 
             
                    version: '0'
         | 
| 165 165 | 
             
              type: :development
         | 
| 166 166 | 
             
              prerelease: false
         | 
| 167 | 
            -
              version_requirements: * | 
| 167 | 
            +
              version_requirements: *2156232440
         | 
| 168 168 | 
             
            description: An XMPP DSL for Ruby written on top of EventMachine and Nokogiri
         | 
| 169 169 | 
             
            email: sprsquish@gmail.com
         | 
| 170 170 | 
             
            executables: []
         | 
| @@ -228,6 +228,8 @@ files: | |
| 228 228 | 
             
            - lib/blather/stanza/iq/si.rb
         | 
| 229 229 | 
             
            - lib/blather/stanza/iq/vcard.rb
         | 
| 230 230 | 
             
            - lib/blather/stanza/message.rb
         | 
| 231 | 
            +
            - lib/blather/stanza/message/muc_user.rb
         | 
| 232 | 
            +
            - lib/blather/stanza/muc/muc_user_base.rb
         | 
| 231 233 | 
             
            - lib/blather/stanza/presence.rb
         | 
| 232 234 | 
             
            - lib/blather/stanza/presence/c.rb
         | 
| 233 235 | 
             
            - lib/blather/stanza/presence/muc.rb
         | 
| @@ -283,6 +285,7 @@ files: | |
| 283 285 | 
             
            - spec/blather/stanza/iq/si_spec.rb
         | 
| 284 286 | 
             
            - spec/blather/stanza/iq/vcard_spec.rb
         | 
| 285 287 | 
             
            - spec/blather/stanza/iq_spec.rb
         | 
| 288 | 
            +
            - spec/blather/stanza/message/muc_user_spec.rb
         | 
| 286 289 | 
             
            - spec/blather/stanza/message_spec.rb
         | 
| 287 290 | 
             
            - spec/blather/stanza/presence/c_spec.rb
         | 
| 288 291 | 
             
            - spec/blather/stanza/presence/muc_spec.rb
         | 
| @@ -365,6 +368,7 @@ test_files: | |
| 365 368 | 
             
            - spec/blather/stanza/iq/si_spec.rb
         | 
| 366 369 | 
             
            - spec/blather/stanza/iq/vcard_spec.rb
         | 
| 367 370 | 
             
            - spec/blather/stanza/iq_spec.rb
         | 
| 371 | 
            +
            - spec/blather/stanza/message/muc_user_spec.rb
         | 
| 368 372 | 
             
            - spec/blather/stanza/message_spec.rb
         | 
| 369 373 | 
             
            - spec/blather/stanza/presence/c_spec.rb
         | 
| 370 374 | 
             
            - spec/blather/stanza/presence/muc_spec.rb
         |