jubjub 0.0.7 → 0.0.8
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/README.mdown +27 -1
 - data/lib/jubjub.rb +1 -1
 - data/lib/jubjub/connection/xmpp_gateway.rb +9 -9
 - data/lib/jubjub/connection/xmpp_gateway/helper.rb +5 -5
 - data/lib/jubjub/connection/xmpp_gateway/muc.rb +127 -32
 - data/lib/jubjub/connection/xmpp_gateway/pubsub.rb +64 -64
 - data/lib/jubjub/data_form.rb +16 -13
 - data/lib/jubjub/errors.rb +2 -2
 - data/lib/jubjub/helpers.rb +32 -0
 - data/lib/jubjub/jid.rb +8 -8
 - data/lib/jubjub/muc.rb +3 -1
 - data/lib/jubjub/muc/affiliation.rb +77 -0
 - data/lib/jubjub/muc/affiliations_collection.rb +31 -0
 - data/lib/jubjub/muc/collection.rb +12 -19
 - data/lib/jubjub/muc/configuration.rb +2 -2
 - data/lib/jubjub/muc/muc.rb +24 -11
 - data/lib/jubjub/pubsub.rb +1 -1
 - data/lib/jubjub/pubsub/affiliation.rb +20 -20
 - data/lib/jubjub/pubsub/affiliation_collection.rb +11 -18
 - data/lib/jubjub/pubsub/collection.rb +14 -21
 - data/lib/jubjub/pubsub/configuration.rb +2 -2
 - data/lib/jubjub/pubsub/item.rb +8 -8
 - data/lib/jubjub/pubsub/item_collection.rb +10 -17
 - data/lib/jubjub/pubsub/pubsub.rb +17 -17
 - data/lib/jubjub/pubsub/subscription.rb +6 -6
 - data/lib/jubjub/response.rb +1 -1
 - data/lib/jubjub/response/error.rb +6 -6
 - data/lib/jubjub/response/proxy.rb +8 -8
 - data/lib/jubjub/response/response.rb +10 -10
 - data/lib/jubjub/user.rb +16 -15
 - data/spec/connection/xmpp_gateway_muc_spec.rb +174 -40
 - data/spec/connection/xmpp_gateway_pubsub_spec.rb +100 -104
 - data/spec/fixtures/vcr_cassettes/muc_configuration.yml +73 -6
 - data/spec/fixtures/vcr_cassettes/muc_create_with_configuration.yml +8 -8
 - data/spec/fixtures/vcr_cassettes/muc_message.yml +89 -0
 - data/spec/fixtures/vcr_cassettes/muc_modify_affiliations.yml +367 -0
 - data/spec/fixtures/vcr_cassettes/muc_retrieve_affiliations.yml +93 -0
 - data/spec/fixtures/vcr_cassettes/pubsub_publish_with_dataform_payload.yml +3 -3
 - data/spec/fixtures/vcr_cassettes/pubsub_retrieve_items.yml +24 -18
 - data/spec/mixins/user_spec.rb +37 -37
 - data/spec/models/data_form_spec.rb +3 -3
 - data/spec/models/jid_spec.rb +41 -41
 - data/spec/models/muc_affiliation_collection_spec.rb +146 -0
 - data/spec/models/muc_affiliation_spec.rb +215 -0
 - data/spec/models/muc_collection_spec.rb +64 -32
 - data/spec/models/muc_configuration_spec.rb +3 -3
 - data/spec/models/muc_spec.rb +44 -23
 - data/spec/models/pubsub_affiliation_collection_spec.rb +65 -30
 - data/spec/models/pubsub_affiliation_spec.rb +50 -50
 - data/spec/models/pubsub_collection_spec.rb +65 -49
 - data/spec/models/pubsub_item_collection_spec.rb +17 -17
 - data/spec/models/pubsub_item_spec.rb +18 -18
 - data/spec/models/pubsub_spec.rb +41 -41
 - data/spec/models/pubsub_subscription_spec.rb +23 -23
 - data/spec/models/response_error_spec.rb +19 -19
 - data/spec/models/response_proxy_spec.rb +51 -49
 - data/spec/models/response_spec.rb +33 -33
 - data/spec/support/helpers.rb +21 -1
 - data/spec/support/matchers.rb +4 -4
 - data/spec/support/shared_examples.rb +132 -94
 - data/spec/support/webmock_stanza_matching.rb +43 -0
 - metadata +45 -16
 
    
        data/lib/jubjub/user.rb
    CHANGED
    
    | 
         @@ -1,4 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'jubjub/errors'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'jubjub/helpers'
         
     | 
| 
       2 
3 
     | 
    
         
             
            require 'jubjub/response'
         
     | 
| 
       3 
4 
     | 
    
         
             
            require 'jubjub/jid'
         
     | 
| 
       4 
5 
     | 
    
         
             
            require 'jubjub/connection/xmpp_gateway'
         
     | 
| 
         @@ -7,13 +8,13 @@ require 'jubjub/muc' 
     | 
|
| 
       7 
8 
     | 
    
         
             
            require 'jubjub/data_form'
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
10 
     | 
    
         
             
            module Jubjub
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       11 
12 
     | 
    
         
             
              module User
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       13 
14 
     | 
    
         
             
                def self.included base
         
     | 
| 
       14 
15 
     | 
    
         
             
                  base.extend ClassMethods
         
     | 
| 
       15 
16 
     | 
    
         
             
                end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
       17 
18 
     | 
    
         
             
                module ClassMethods
         
     | 
| 
       18 
19 
     | 
    
         
             
                  def jubjub_client options = {}
         
     | 
| 
       19 
20 
     | 
    
         
             
                    # Setup defaults
         
     | 
| 
         @@ -21,49 +22,49 @@ module Jubjub 
     | 
|
| 
       21 
22 
     | 
    
         
             
                      :host => '127.0.0.1',
         
     | 
| 
       22 
23 
     | 
    
         
             
                      :port => '8000'
         
     | 
| 
       23 
24 
     | 
    
         
             
                    }.merge options[:connection_settings] || {}
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
       25 
26 
     | 
    
         
             
                    [:jid, :password].each do |key|
         
     | 
| 
       26 
27 
     | 
    
         
             
                      raise Jubjub::ArgumentError.new("missing :#{key} option") unless options.has_key? key
         
     | 
| 
       27 
28 
     | 
    
         
             
                    end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
       29 
30 
     | 
    
         
             
                    define_method "jubjub_jid" do
         
     | 
| 
       30 
31 
     | 
    
         
             
                      Jubjub::Jid.new(send(options[:jid]))
         
     | 
| 
       31 
32 
     | 
    
         
             
                    end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
       33 
34 
     | 
    
         
             
                    define_method "jubjub_password" do
         
     | 
| 
       34 
35 
     | 
    
         
             
                      send(options[:password])
         
     | 
| 
       35 
36 
     | 
    
         
             
                    end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
       37 
38 
     | 
    
         
             
                    define_method "jubjub_connection_settings" do
         
     | 
| 
       38 
39 
     | 
    
         
             
                      default_connection_settings
         
     | 
| 
       39 
40 
     | 
    
         
             
                    end
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
       41 
42 
     | 
    
         
             
                    include InstanceMethods
         
     | 
| 
       42 
43 
     | 
    
         
             
                  end
         
     | 
| 
       43 
44 
     | 
    
         
             
                end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
       45 
46 
     | 
    
         
             
                module InstanceMethods
         
     | 
| 
       46 
47 
     | 
    
         
             
                  def jubjub_connection
         
     | 
| 
       47 
48 
     | 
    
         
             
                    @jubjub_connection ||= Jubjub::Connection::XmppGateway.new(jubjub_jid, jubjub_password, jubjub_connection_settings)
         
     | 
| 
       48 
49 
     | 
    
         
             
                  end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
       50 
51 
     | 
    
         
             
                  def authenticated?
         
     | 
| 
       51 
52 
     | 
    
         
             
                    jubjub_connection.authenticated?
         
     | 
| 
       52 
53 
     | 
    
         
             
                  end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
       54 
55 
     | 
    
         
             
                  # List muc rooms
         
     | 
| 
       55 
56 
     | 
    
         
             
                  # if no jid is specified will default to 'connection.JID_DOMAIN'
         
     | 
| 
       56 
57 
     | 
    
         
             
                  def mucs(jid = nil)
         
     | 
| 
       57 
58 
     | 
    
         
             
                    jid ||= "conference.#{jubjub_jid.domain}"
         
     | 
| 
       58 
59 
     | 
    
         
             
                    Jubjub::Muc::Collection.new jid, jubjub_connection
         
     | 
| 
       59 
60 
     | 
    
         
             
                  end
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
       61 
62 
     | 
    
         
             
                  def pubsub(jid = nil)
         
     | 
| 
       62 
63 
     | 
    
         
             
                    jid ||= "pubsub.#{jubjub_jid.domain}"
         
     | 
| 
       63 
64 
     | 
    
         
             
                    Jubjub::Pubsub::Collection.new jid, jubjub_connection
         
     | 
| 
       64 
65 
     | 
    
         
             
                  end
         
     | 
| 
       65 
66 
     | 
    
         
             
                end
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
       67 
68 
     | 
    
         
             
              end
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
            end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,54 +1,59 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe Jubjub::Connection::XmppGateway do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       5 
5 
     | 
    
         
             
              before do
         
     | 
| 
       6 
6 
     | 
    
         
             
                @connection = Jubjub::Connection::XmppGateway.new('theozaurus@theo-template.local','secret', {:host => '127.0.0.1', :port => '8000'})
         
     | 
| 
       7 
7 
     | 
    
         
             
              end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       9 
9 
     | 
    
         
             
              describe "muc" do
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       11 
11 
     | 
    
         
             
                describe "create" do
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
       13 
13 
     | 
    
         
             
                  use_vcr_cassette 'muc create', :record => :new_episodes
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
       15 
15 
     | 
    
         
             
                  it "return a Jubjub::Muc" do
         
     | 
| 
       16 
16 
     | 
    
         
             
                    @room = @connection.muc.create( Jubjub::Jid.new 'room@conference.theo-template.local/nick' )
         
     | 
| 
       17 
17 
     | 
    
         
             
                    @room.should be_a_kind_of_response_proxied Jubjub::Muc
         
     | 
| 
       18 
18 
     | 
    
         
             
                    @room.jid.should == Jubjub::Jid.new( 'room@conference.theo-template.local' )
         
     | 
| 
       19 
19 
     | 
    
         
             
                  end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       21 
21 
     | 
    
         
             
                  after do
         
     | 
| 
       22 
22 
     | 
    
         
             
                    @room.destroy
         
     | 
| 
       23 
23 
     | 
    
         
             
                  end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       25 
25 
     | 
    
         
             
                end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       27 
27 
     | 
    
         
             
                describe "create with configuration" do
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
       29 
29 
     | 
    
         
             
                  use_vcr_cassette 'muc create with configuration', :record => :new_episodes
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       31 
31 
     | 
    
         
             
                  it "return a Jubjub::Muc" do
         
     | 
| 
       32 
32 
     | 
    
         
             
                    @config = Jubjub::Muc::Configuration.new("allow_query_users" => { :type => "boolean", :value => "1", :label => "Allow users to query other users" })
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
       34 
34 
     | 
    
         
             
                    @room = @connection.muc.create( Jubjub::Jid.new( 'room@conference.theo-template.local/nick' ), @config )
         
     | 
| 
       35 
35 
     | 
    
         
             
                    @room.should be_a_kind_of_response_proxied Jubjub::Muc
         
     | 
| 
       36 
36 
     | 
    
         
             
                    @room.jid.should == Jubjub::Jid.new( 'room@conference.theo-template.local' )
         
     | 
| 
       37 
37 
     | 
    
         
             
                  end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       39 
39 
     | 
    
         
             
                  after do
         
     | 
| 
       40 
40 
     | 
    
         
             
                    @room.destroy
         
     | 
| 
       41 
41 
     | 
    
         
             
                  end
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
       43 
43 
     | 
    
         
             
                end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
       45 
45 
     | 
    
         
             
                describe "configuration" do
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
       47 
47 
     | 
    
         
             
                  use_vcr_cassette 'muc configuration', :record => :new_episodes
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 50 
     | 
    
         
            +
                    @jid = Jubjub::Jid.new 'configuration@conference.theo-template.local/nick'
         
     | 
| 
      
 51 
     | 
    
         
            +
                    @room = @connection.muc.create @jid
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
       49 
54 
     | 
    
         
             
                  it "return a Jubjub::Muc::Configuration" do
         
     | 
| 
       50 
     | 
    
         
            -
                    config = @connection.muc.configuration 
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
      
 55 
     | 
    
         
            +
                    config = @connection.muc.configuration @jid
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
       52 
57 
     | 
    
         
             
                    expected_config = {
         
     | 
| 
       53 
58 
     | 
    
         
             
                      "allow_query_users"                     => { :type => "boolean", :value => "1", :label => "Allow users to query other users" },
         
     | 
| 
       54 
59 
     | 
    
         
             
                      "allow_private_messages"                => { :type => "boolean", :value => "1", :label => "Allow users to send private messages" },
         
     | 
| 
         @@ -87,72 +92,201 @@ describe Jubjub::Connection::XmppGateway do 
     | 
|
| 
       87 
92 
     | 
    
         
             
                          { :value => "100", :label => "100" },
         
     | 
| 
       88 
93 
     | 
    
         
             
                          { :value => "200", :label => "200" }]}
         
     | 
| 
       89 
94 
     | 
    
         
             
                    }
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
       91 
96 
     | 
    
         
             
                    config.should == Jubjub::Muc::Configuration.new(expected_config)
         
     | 
| 
       92 
97 
     | 
    
         
             
                  end
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                  after do
         
     | 
| 
      
 100 
     | 
    
         
            +
                    @room.destroy
         
     | 
| 
      
 101 
     | 
    
         
            +
                  end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
       94 
103 
     | 
    
         
             
                end
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
       96 
105 
     | 
    
         
             
                describe "list" do
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
       98 
107 
     | 
    
         
             
                  use_vcr_cassette 'muc list', :record => :new_episodes
         
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
       100 
109 
     | 
    
         
             
                  before do
         
     | 
| 
       101 
110 
     | 
    
         
             
                    @connection.muc.create Jubjub::Jid.new( 'test_1@conference.theo-template.local/nick' )
         
     | 
| 
       102 
111 
     | 
    
         
             
                    @connection.muc.create Jubjub::Jid.new( 'test_2@conference.theo-template.local/nick' )
         
     | 
| 
       103 
112 
     | 
    
         
             
                  end
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
       105 
114 
     | 
    
         
             
                  it "return an array of Jubjub::Muc" do
         
     | 
| 
       106 
115 
     | 
    
         
             
                    list = @connection.muc.list( Jubjub::Jid.new 'conference.theo-template.local' )
         
     | 
| 
       107 
116 
     | 
    
         
             
                    list.should be_a_kind_of_response_proxied Array
         
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
       109 
118 
     | 
    
         
             
                    list.size.should eql(2)
         
     | 
| 
       110 
119 
     | 
    
         
             
                    list[0].should be_a_kind_of Jubjub::Muc
         
     | 
| 
       111 
120 
     | 
    
         
             
                    list[0].jid.should == Jubjub::Jid.new( 'test_1@conference.theo-template.local' )
         
     | 
| 
       112 
121 
     | 
    
         
             
                    list[1].should be_a_kind_of Jubjub::Muc
         
     | 
| 
       113 
122 
     | 
    
         
             
                    list[1].jid.should == Jubjub::Jid.new( 'test_2@conference.theo-template.local' )
         
     | 
| 
       114 
123 
     | 
    
         
             
                  end
         
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
       116 
125 
     | 
    
         
             
                end
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                describe "retrieve_affiliations" do
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                  use_vcr_cassette 'muc retrieve_affiliations', :record => :new_episodes
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 132 
     | 
    
         
            +
                    @room_full = Jubjub::Jid.new( 'retrieve_affiliations@conference.theo-template.local/theozaurus' )
         
     | 
| 
      
 133 
     | 
    
         
            +
                    @room = Jubjub::Jid.new @room_full.node, @room_full.domain
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                    @connection.muc.create @room_full
         
     | 
| 
      
 136 
     | 
    
         
            +
                  end
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
                  it "return an array of Jubjub::Muc::Affiliation" do
         
     | 
| 
      
 139 
     | 
    
         
            +
                    list = @connection.muc.retrieve_affiliations @room, 'owner'
         
     | 
| 
      
 140 
     | 
    
         
            +
                    list.should be_a_kind_of_response_proxied Array
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                    list.size.should eql(1)
         
     | 
| 
      
 143 
     | 
    
         
            +
                    list[0].should be_a_kind_of Jubjub::Muc::Affiliation
         
     | 
| 
      
 144 
     | 
    
         
            +
                    list[0].jid.should == Jubjub::Jid.new( 'theozaurus@theo-template.local' )
         
     | 
| 
      
 145 
     | 
    
         
            +
                    list[0].role.should == nil
         
     | 
| 
      
 146 
     | 
    
         
            +
                    list[0].affiliation.should == "owner"
         
     | 
| 
      
 147 
     | 
    
         
            +
                    list[0].nick.should == nil
         
     | 
| 
      
 148 
     | 
    
         
            +
                  end
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
                  after do
         
     | 
| 
      
 151 
     | 
    
         
            +
                    @connection.muc.destroy @room
         
     | 
| 
      
 152 
     | 
    
         
            +
                  end
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
                end
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
                describe "modify_affiliations" do
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
                  use_vcr_cassette 'muc modify_affiliations', :record => :new_episodes
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
      
 160 
     | 
    
         
            +
                  it "should return true when successful" do
         
     | 
| 
      
 161 
     | 
    
         
            +
                    room_full = Jubjub::Jid.new 'modify_affiliations_1@conference.theo-template.local/foo'
         
     | 
| 
      
 162 
     | 
    
         
            +
                    room = Jubjub::Jid.new room_full.node, room_full.domain
         
     | 
| 
      
 163 
     | 
    
         
            +
                    @connection.muc.create room_full
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
                    affiliation = muc_affiliation_factory :muc_jid => room,
         
     | 
| 
      
 166 
     | 
    
         
            +
                                                          :jid => 'ed@theo-template.local',
         
     | 
| 
      
 167 
     | 
    
         
            +
                                                          :affiliation => 'owner',
         
     | 
| 
      
 168 
     | 
    
         
            +
                                                          :connection => @connection
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
                    @connection.muc.modify_affiliations( room, affiliation).should equal(true)
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
                    @connection.muc.destroy room
         
     | 
| 
      
 173 
     | 
    
         
            +
                  end
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
                  it "should allow affiliations to be specified as an array" do
         
     | 
| 
      
 176 
     | 
    
         
            +
                    room_full = Jubjub::Jid.new 'modify_affiliations_2@conference.theo-template.local/foo'
         
     | 
| 
      
 177 
     | 
    
         
            +
                    room = Jubjub::Jid.new room_full.node, room_full.domain
         
     | 
| 
      
 178 
     | 
    
         
            +
                    @connection.muc.create room_full
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
                    affiliation_1 = muc_affiliation_factory :muc_jid => room,
         
     | 
| 
      
 181 
     | 
    
         
            +
                                                            :jid => 'ed@theo-template.local',
         
     | 
| 
      
 182 
     | 
    
         
            +
                                                            :affiliation => 'owner',
         
     | 
| 
      
 183 
     | 
    
         
            +
                                                            :connection => @connection
         
     | 
| 
      
 184 
     | 
    
         
            +
                    affiliation_2 = muc_affiliation_factory :muc_jid => room,
         
     | 
| 
      
 185 
     | 
    
         
            +
                                                            :jid => 'bob@theo-template.local',
         
     | 
| 
      
 186 
     | 
    
         
            +
                                                            :affiliation => 'member',
         
     | 
| 
      
 187 
     | 
    
         
            +
                                                            :connection => @connection
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                    @connection.muc.modify_affiliations room, [affiliation_1, affiliation_2]
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
                    @connection.muc.destroy room
         
     | 
| 
      
 192 
     | 
    
         
            +
                  end
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
                  it "should allow affiliations to be specified as arguments" do
         
     | 
| 
      
 195 
     | 
    
         
            +
                    room_full = Jubjub::Jid.new 'modify_affiliations_3@conference.theo-template.local/foo'
         
     | 
| 
      
 196 
     | 
    
         
            +
                    room = Jubjub::Jid.new room_full.node, room_full.domain
         
     | 
| 
      
 197 
     | 
    
         
            +
                    @connection.muc.create room_full
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                    affiliation_1 = muc_affiliation_factory :muc_jid => room,
         
     | 
| 
      
 200 
     | 
    
         
            +
                                                            :jid => 'ed@theo-template.local',
         
     | 
| 
      
 201 
     | 
    
         
            +
                                                            :affiliation => 'owner',
         
     | 
| 
      
 202 
     | 
    
         
            +
                                                            :connection => @connection
         
     | 
| 
      
 203 
     | 
    
         
            +
                    affiliation_2 = muc_affiliation_factory :muc_jid => room,
         
     | 
| 
      
 204 
     | 
    
         
            +
                                                            :jid => 'bob@theo-template.local',
         
     | 
| 
      
 205 
     | 
    
         
            +
                                                            :affiliation => 'member',
         
     | 
| 
      
 206 
     | 
    
         
            +
                                                            :connection => @connection
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
      
 208 
     | 
    
         
            +
                    @connection.muc.modify_affiliations room, affiliation_1, affiliation_2
         
     | 
| 
      
 209 
     | 
    
         
            +
             
     | 
| 
      
 210 
     | 
    
         
            +
                    @connection.muc.destroy room
         
     | 
| 
      
 211 
     | 
    
         
            +
                  end
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
      
 213 
     | 
    
         
            +
                  it "should return false if unsuccessful" do
         
     | 
| 
      
 214 
     | 
    
         
            +
                    room_full = Jubjub::Jid.new 'modify_affiliations_4@conference.theo-template.local/foo'
         
     | 
| 
      
 215 
     | 
    
         
            +
                    room = Jubjub::Jid.new room_full.node, room_full.domain
         
     | 
| 
      
 216 
     | 
    
         
            +
                    @connection.muc.create room_full
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
      
 218 
     | 
    
         
            +
                    affiliation = muc_affiliation_factory :muc_jid => room,
         
     | 
| 
      
 219 
     | 
    
         
            +
                                                          :jid => 'ed@theo-template.local',
         
     | 
| 
      
 220 
     | 
    
         
            +
                                                          :affiliation => 'WIBBLE',
         
     | 
| 
      
 221 
     | 
    
         
            +
                                                          :connection => @connection
         
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
                    @connection.muc.modify_affiliations( room, affiliation ).should equal(false)
         
     | 
| 
      
 224 
     | 
    
         
            +
             
     | 
| 
      
 225 
     | 
    
         
            +
                    @connection.muc.destroy room
         
     | 
| 
      
 226 
     | 
    
         
            +
                  end
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
                end
         
     | 
| 
      
 229 
     | 
    
         
            +
             
     | 
| 
      
 230 
     | 
    
         
            +
                describe "message" do
         
     | 
| 
      
 231 
     | 
    
         
            +
                  use_vcr_cassette 'muc message', :record => :new_episodes
         
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
      
 233 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 234 
     | 
    
         
            +
                    @full_jid = Jubjub::Jid.new 'message@conference.theo-template.local/nick'
         
     | 
| 
      
 235 
     | 
    
         
            +
                    @jid = Jubjub::Jid.new 'message@conference.theo-template.local'
         
     | 
| 
      
 236 
     | 
    
         
            +
                    @connection.muc.create(@full_jid)
         
     | 
| 
      
 237 
     | 
    
         
            +
                  end
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
                  it "should send correct stanza" do
         
     | 
| 
      
 240 
     | 
    
         
            +
                    # will attempt to create new vcr cassette if the stanza is wrong
         
     | 
| 
      
 241 
     | 
    
         
            +
                    # relies on cassette being manually checked
         
     | 
| 
      
 242 
     | 
    
         
            +
                    @connection.muc.message(@jid, "Jubjub here!")
         
     | 
| 
      
 243 
     | 
    
         
            +
                  end
         
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
                  after do
         
     | 
| 
      
 246 
     | 
    
         
            +
                    # Just incase the room is persistent
         
     | 
| 
      
 247 
     | 
    
         
            +
                    @connection.muc.destroy(@jid)
         
     | 
| 
      
 248 
     | 
    
         
            +
                  end
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
                end
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
       118 
252 
     | 
    
         
             
                describe "exit" do
         
     | 
| 
       119 
253 
     | 
    
         
             
                  use_vcr_cassette 'muc exit', :record => :new_episodes
         
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
      
 254 
     | 
    
         
            +
             
     | 
| 
       121 
255 
     | 
    
         
             
                  before do
         
     | 
| 
       122 
256 
     | 
    
         
             
                    @full_jid = Jubjub::Jid.new 'extra@conference.theo-template.local/nick'
         
     | 
| 
       123 
257 
     | 
    
         
             
                    @jid = Jubjub::Jid.new 'extra@conference.theo-template.local'
         
     | 
| 
       124 
258 
     | 
    
         
             
                    @connection.muc.create(@full_jid)
         
     | 
| 
       125 
259 
     | 
    
         
             
                  end
         
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
      
 260 
     | 
    
         
            +
             
     | 
| 
       127 
261 
     | 
    
         
             
                  it "should send correct stanza" do
         
     | 
| 
       128 
262 
     | 
    
         
             
                    # will attempt to create new vcr cassette if the stanza is wrong
         
     | 
| 
       129 
263 
     | 
    
         
             
                    # relies on cassette being manually checked
         
     | 
| 
       130 
264 
     | 
    
         
             
                    @connection.muc.exit(@full_jid)
         
     | 
| 
       131 
265 
     | 
    
         
             
                  end
         
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
      
 266 
     | 
    
         
            +
             
     | 
| 
       133 
267 
     | 
    
         
             
                  after do
         
     | 
| 
       134 
268 
     | 
    
         
             
                    # Just incase the room is persistent
         
     | 
| 
       135 
     | 
    
         
            -
                    @connection.muc.destroy(@jid) 
     | 
| 
      
 269 
     | 
    
         
            +
                    @connection.muc.destroy(@jid)
         
     | 
| 
       136 
270 
     | 
    
         
             
                  end
         
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
      
 271 
     | 
    
         
            +
             
     | 
| 
       138 
272 
     | 
    
         
             
                end
         
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
      
 273 
     | 
    
         
            +
             
     | 
| 
       140 
274 
     | 
    
         
             
                describe "destroy" do
         
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
       142 
276 
     | 
    
         
             
                  use_vcr_cassette 'muc destroy', :record => :new_episodes
         
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
       144 
278 
     | 
    
         
             
                  before do
         
     | 
| 
       145 
279 
     | 
    
         
             
                    @jid      = Jubjub::Jid.new 'extra@conference.theo-template.local'
         
     | 
| 
       146 
280 
     | 
    
         
             
                    @full_jid = Jubjub::Jid.new 'extra@conference.theo-template.local/nick'
         
     | 
| 
       147 
281 
     | 
    
         
             
                    @connection.muc.create @full_jid
         
     | 
| 
       148 
282 
     | 
    
         
             
                  end
         
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
      
 283 
     | 
    
         
            +
             
     | 
| 
       150 
284 
     | 
    
         
             
                  it "return true" do
         
     | 
| 
       151 
285 
     | 
    
         
             
                    @connection.muc.destroy( @jid ).should be_true
         
     | 
| 
       152 
286 
     | 
    
         
             
                  end
         
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
      
 287 
     | 
    
         
            +
             
     | 
| 
       154 
288 
     | 
    
         
             
                end
         
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
      
 289 
     | 
    
         
            +
             
     | 
| 
       156 
290 
     | 
    
         
             
              end
         
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
            end
         
     | 
| 
      
 291 
     | 
    
         
            +
             
     | 
| 
      
 292 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,34 +1,34 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe Jubjub::Connection::XmppGateway do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       5 
5 
     | 
    
         
             
              before do
         
     | 
| 
       6 
6 
     | 
    
         
             
                @jid = Jubjub::Jid.new('theozaurus@theo-template.local')
         
     | 
| 
       7 
7 
     | 
    
         
             
                @connection = Jubjub::Connection::XmppGateway.new(@jid, 'secret', {:host => '127.0.0.1', :port => '8000'})
         
     | 
| 
       8 
8 
     | 
    
         
             
              end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
       10 
10 
     | 
    
         
             
              describe "pubsub" do
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       12 
12 
     | 
    
         
             
                describe "create" do
         
     | 
| 
       13 
13 
     | 
    
         
             
                  use_vcr_cassette 'pubsub create', :record => :new_episodes
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                  it "return a Jubjub::Pubsub" do
         
     | 
| 
       16 
16 
     | 
    
         
             
                    @pubsub = @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
       18 
18 
     | 
    
         
             
                    @pubsub.should be_a_kind_of_response_proxied Jubjub::Pubsub
         
     | 
| 
       19 
19 
     | 
    
         
             
                    @pubsub.jid.should == Jubjub::Jid.new('pubsub.theo-template.local')
         
     | 
| 
       20 
20 
     | 
    
         
             
                    @pubsub.node.should == 'node_1'
         
     | 
| 
       21 
21 
     | 
    
         
             
                  end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       23 
23 
     | 
    
         
             
                  after do
         
     | 
| 
       24 
24 
     | 
    
         
             
                    # Clean up the node
         
     | 
| 
       25 
25 
     | 
    
         
             
                    @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       26 
26 
     | 
    
         
             
                  end
         
     | 
| 
       27 
27 
     | 
    
         
             
                end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
       29 
29 
     | 
    
         
             
                describe "default_configuration" do
         
     | 
| 
       30 
30 
     | 
    
         
             
                  use_vcr_cassette 'pubsub default configuration', :record => :new_episodes
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
       32 
32 
     | 
    
         
             
                  it "should return a Jubjub::Pubsub::Configuration" do
         
     | 
| 
       33 
33 
     | 
    
         
             
                    expected_config = {
         
     | 
| 
       34 
34 
     | 
    
         
             
                      "pubsub#deliver_payloads" => { :type => "boolean", :value => "1", :label => "Deliver payloads with event notifications" },
         
     | 
| 
         @@ -79,77 +79,73 @@ describe Jubjub::Connection::XmppGateway do 
     | 
|
| 
       79 
79 
     | 
    
         
             
                          { :value => "headline", :label => nil },
         
     | 
| 
       80 
80 
     | 
    
         
             
                          { :value => "normal",   :label => nil }]}
         
     | 
| 
       81 
81 
     | 
    
         
             
                    }
         
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
       83 
83 
     | 
    
         
             
                    config = @connection.pubsub.default_configuration 'pubsub.theo-template.local'
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
       85 
85 
     | 
    
         
             
                    config.should be_a_kind_of_response_proxied Jubjub::Pubsub::Configuration
         
     | 
| 
       86 
     | 
    
         
            -
                    config.should == Jubjub::Pubsub::Configuration.new( expected_config ) 
     | 
| 
      
 86 
     | 
    
         
            +
                    config.should == Jubjub::Pubsub::Configuration.new( expected_config )
         
     | 
| 
       87 
87 
     | 
    
         
             
                  end
         
     | 
| 
       88 
88 
     | 
    
         
             
                end
         
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
       90 
90 
     | 
    
         
             
                describe "destroy" do
         
     | 
| 
       91 
91 
     | 
    
         
             
                  use_vcr_cassette 'pubsub destroy', :record => :new_episodes
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
       93 
93 
     | 
    
         
             
                  before do
         
     | 
| 
       94 
94 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       95 
95 
     | 
    
         
             
                  end
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
       97 
97 
     | 
    
         
             
                  it "should send correct stanza" do
         
     | 
| 
       98 
98 
     | 
    
         
             
                    # will attempt to create new vcr cassette if the stanza is wrong
         
     | 
| 
       99 
99 
     | 
    
         
             
                    # relies on cassette being manually checked
         
     | 
| 
       100 
100 
     | 
    
         
             
                    @connection.pubsub.destroy('pubsub.theo-template.local', 'node_1').should be_true
         
     | 
| 
       101 
101 
     | 
    
         
             
                  end
         
     | 
| 
       102 
102 
     | 
    
         
             
                end
         
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
       104 
104 
     | 
    
         
             
                describe "purge" do
         
     | 
| 
       105 
105 
     | 
    
         
             
                  use_vcr_cassette 'pubsub purge', :record => :new_episodes
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
       107 
107 
     | 
    
         
             
                  before do
         
     | 
| 
       108 
108 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_pubsub_purge'
         
     | 
| 
       109 
109 
     | 
    
         
             
                  end
         
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
       111 
111 
     | 
    
         
             
                  it "should send correct stanza" do
         
     | 
| 
       112 
112 
     | 
    
         
             
                    # will attempt to create new vcr cassette if the stanza is wrong
         
     | 
| 
       113 
113 
     | 
    
         
             
                    # relies on cassette being manually checked
         
     | 
| 
       114 
114 
     | 
    
         
             
                    @connection.pubsub.purge('pubsub.theo-template.local', 'node_pubsub_purge').should be_true
         
     | 
| 
       115 
115 
     | 
    
         
             
                  end
         
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
       117 
117 
     | 
    
         
             
                  after do
         
     | 
| 
       118 
118 
     | 
    
         
             
                    @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_pubsub_purge'
         
     | 
| 
       119 
119 
     | 
    
         
             
                  end
         
     | 
| 
       120 
120 
     | 
    
         
             
                end
         
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
       122 
122 
     | 
    
         
             
                describe "list" do
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
       124 
124 
     | 
    
         
             
                  use_vcr_cassette 'pubsub list', :record => :new_episodes
         
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
       126 
126 
     | 
    
         
             
                  before do
         
     | 
| 
       127 
127 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       128 
128 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_2'
         
     | 
| 
       129 
129 
     | 
    
         
             
                  end
         
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
       131 
131 
     | 
    
         
             
                  it "return an array of Jubjub::Muc" do
         
     | 
| 
       132 
132 
     | 
    
         
             
                    list = @connection.pubsub.list 'pubsub.theo-template.local'
         
     | 
| 
       133 
133 
     | 
    
         
             
                    list.should be_a_kind_of_response_proxied Array
         
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
                    list. 
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
                    list[1].should be_a_kind_of Jubjub::Pubsub
         
     | 
| 
       139 
     | 
    
         
            -
                    list[1].node.should == 'node_2'
         
     | 
| 
       140 
     | 
    
         
            -
                  end
         
     | 
| 
       141 
     | 
    
         
            -
                  
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                    list.map{|item| item.node }.to_set.should == ['node_1', 'node_2'].to_set
         
     | 
| 
      
 136 
     | 
    
         
            +
                  end
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
       142 
138 
     | 
    
         
             
                  after do
         
     | 
| 
       143 
139 
     | 
    
         
             
                    @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       144 
140 
     | 
    
         
             
                    @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_2'
         
     | 
| 
       145 
141 
     | 
    
         
             
                  end
         
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
       147 
143 
     | 
    
         
             
                end
         
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
       149 
145 
     | 
    
         
             
                describe "destroy with redirect" do
         
     | 
| 
       150 
146 
     | 
    
         
             
                  use_vcr_cassette 'pubsub destroy with redirect', :record => :new_episodes
         
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
                  before do 
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
                  before do
         
     | 
| 
       153 
149 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       154 
150 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_2'
         
     | 
| 
       155 
151 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -157,22 +153,22 @@ describe Jubjub::Connection::XmppGateway do 
     | 
|
| 
       157 
153 
     | 
    
         
             
                  it "should support redirects" do
         
     | 
| 
       158 
154 
     | 
    
         
             
                    @connection.pubsub.destroy('pubsub.theo-template.local', 'node_1', 'pubsub.theo-template.local', 'node_2').should be_true
         
     | 
| 
       159 
155 
     | 
    
         
             
                  end
         
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
       161 
157 
     | 
    
         
             
                  after do
         
     | 
| 
       162 
158 
     | 
    
         
             
                    @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_2'
         
     | 
| 
       163 
159 
     | 
    
         
             
                  end
         
     | 
| 
       164 
160 
     | 
    
         
             
                end
         
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
       166 
162 
     | 
    
         
             
                describe "subscribe" do
         
     | 
| 
       167 
163 
     | 
    
         
             
                  use_vcr_cassette 'pubsub subscribe', :record => :new_episodes
         
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
       169 
165 
     | 
    
         
             
                  before do
         
     | 
| 
       170 
166 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       171 
167 
     | 
    
         
             
                  end
         
     | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
       173 
169 
     | 
    
         
             
                  it "return a Jubjub::Pubsub::Subscription" do
         
     | 
| 
       174 
170 
     | 
    
         
             
                    @subscription = @connection.pubsub.subscribe( 'pubsub.theo-template.local', 'node_1' )
         
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
       176 
172 
     | 
    
         
             
                    @subscription.should be_a_kind_of_response_proxied Jubjub::Pubsub::Subscription
         
     | 
| 
       177 
173 
     | 
    
         
             
                    @subscription.jid.should == Jubjub::Jid.new('pubsub.theo-template.local')
         
     | 
| 
       178 
174 
     | 
    
         
             
                    @subscription.node.should == 'node_1'
         
     | 
| 
         @@ -180,232 +176,232 @@ describe Jubjub::Connection::XmppGateway do 
     | 
|
| 
       180 
176 
     | 
    
         
             
                    @subscription.subscription.should == "subscribed"
         
     | 
| 
       181 
177 
     | 
    
         
             
                    @subscription.subid.should be_kind_of(String)
         
     | 
| 
       182 
178 
     | 
    
         
             
                  end
         
     | 
| 
       183 
     | 
    
         
            -
             
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
       184 
180 
     | 
    
         
             
                  after do
         
     | 
| 
       185 
181 
     | 
    
         
             
                    # Clean up the node
         
     | 
| 
       186 
182 
     | 
    
         
             
                    @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       187 
183 
     | 
    
         
             
                  end
         
     | 
| 
       188 
     | 
    
         
            -
             
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
       189 
185 
     | 
    
         
             
                end
         
     | 
| 
       190 
     | 
    
         
            -
             
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
       191 
187 
     | 
    
         
             
                describe "unsubscribe" do
         
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
       193 
189 
     | 
    
         
             
                  use_vcr_cassette 'pubsub unsubscribe', :record => :new_episodes
         
     | 
| 
       194 
     | 
    
         
            -
             
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
       195 
191 
     | 
    
         
             
                  before do
         
     | 
| 
       196 
192 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       197 
193 
     | 
    
         
             
                    @connection.pubsub.subscribe 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       198 
194 
     | 
    
         
             
                  end
         
     | 
| 
       199 
     | 
    
         
            -
             
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
       200 
196 
     | 
    
         
             
                  it "return true" do
         
     | 
| 
       201 
197 
     | 
    
         
             
                    @connection.pubsub.unsubscribe( 'pubsub.theo-template.local', 'node_1' ).should be_true
         
     | 
| 
       202 
198 
     | 
    
         
             
                  end
         
     | 
| 
       203 
     | 
    
         
            -
             
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
       204 
200 
     | 
    
         
             
                  after do
         
     | 
| 
       205 
201 
     | 
    
         
             
                    # Clean up the node
         
     | 
| 
       206 
202 
     | 
    
         
             
                    @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       207 
203 
     | 
    
         
             
                  end
         
     | 
| 
       208 
     | 
    
         
            -
             
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
       209 
205 
     | 
    
         
             
                end
         
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
       211 
207 
     | 
    
         
             
                describe "unsubscribe with subid" do
         
     | 
| 
       212 
208 
     | 
    
         
             
                  use_vcr_cassette 'pubsub unsubscribe with subid', :record => :new_episodes
         
     | 
| 
       213 
     | 
    
         
            -
             
     | 
| 
      
 209 
     | 
    
         
            +
             
     | 
| 
       214 
210 
     | 
    
         
             
                  before do
         
     | 
| 
       215 
211 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       216 
212 
     | 
    
         
             
                    @subscription = @connection.pubsub.subscribe 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       217 
213 
     | 
    
         
             
                  end
         
     | 
| 
       218 
     | 
    
         
            -
             
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
       219 
215 
     | 
    
         
             
                  it "return true" do
         
     | 
| 
       220 
216 
     | 
    
         
             
                    @connection.pubsub.unsubscribe( 'pubsub.theo-template.local', 'node_1', @subscription.subid ).should be_true
         
     | 
| 
       221 
217 
     | 
    
         
             
                  end
         
     | 
| 
       222 
     | 
    
         
            -
             
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
       223 
219 
     | 
    
         
             
                  after do
         
     | 
| 
       224 
220 
     | 
    
         
             
                    # Clean up the node
         
     | 
| 
       225 
221 
     | 
    
         
             
                    @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       226 
222 
     | 
    
         
             
                  end
         
     | 
| 
       227 
     | 
    
         
            -
             
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
       228 
224 
     | 
    
         
             
                end
         
     | 
| 
       229 
     | 
    
         
            -
             
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
       230 
226 
     | 
    
         
             
                describe "publish" do
         
     | 
| 
       231 
227 
     | 
    
         
             
                  use_vcr_cassette 'pubsub setup node', :record => :new_episodes
         
     | 
| 
       232 
     | 
    
         
            -
             
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
       233 
229 
     | 
    
         
             
                  before do
         
     | 
| 
       234 
230 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       235 
231 
     | 
    
         
             
                  end
         
     | 
| 
       236 
     | 
    
         
            -
             
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
       237 
233 
     | 
    
         
             
                  describe "with id" do
         
     | 
| 
       238 
234 
     | 
    
         
             
                    use_vcr_cassette 'pubsub publish with id', :record => :new_episodes
         
     | 
| 
       239 
     | 
    
         
            -
             
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
       240 
236 
     | 
    
         
             
                    it "should return a Jubjub::Pubsub::Item" do
         
     | 
| 
       241 
237 
     | 
    
         
             
                      i = @connection.pubsub.publish 'pubsub.theo-template.local', 'node_1', Jubjub::DataForm.new, '123'
         
     | 
| 
       242 
238 
     | 
    
         
             
                      i.should be_a_kind_of_response_proxied Jubjub::Pubsub::Item
         
     | 
| 
       243 
239 
     | 
    
         
             
                      i.item_id.should == '123'
         
     | 
| 
       244 
     | 
    
         
            -
                      i.data.should  
     | 
| 
      
 240 
     | 
    
         
            +
                      i.data.should be_equivalent_to('<x xmlns="jabber:x:data" type="submit"/>')
         
     | 
| 
       245 
241 
     | 
    
         
             
                    end
         
     | 
| 
       246 
     | 
    
         
            -
             
     | 
| 
      
 242 
     | 
    
         
            +
             
     | 
| 
       247 
243 
     | 
    
         
             
                  end
         
     | 
| 
       248 
     | 
    
         
            -
             
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
       249 
245 
     | 
    
         
             
                  describe "with string payload" do
         
     | 
| 
       250 
246 
     | 
    
         
             
                    use_vcr_cassette 'pubsub publish with string payload', :record => :new_episodes
         
     | 
| 
       251 
     | 
    
         
            -
             
     | 
| 
      
 247 
     | 
    
         
            +
             
     | 
| 
       252 
248 
     | 
    
         
             
                    it "should return a Jubjub::Pubsub::Item" do
         
     | 
| 
       253 
     | 
    
         
            -
                      item =  
     | 
| 
      
 249 
     | 
    
         
            +
                      item = '<x xmlns="jabber:x:data" type="submit"><field var="foo"><value>true</value></field></x>'
         
     | 
| 
       254 
250 
     | 
    
         
             
                      i = @connection.pubsub.publish 'pubsub.theo-template.local', 'node_1', item
         
     | 
| 
       255 
251 
     | 
    
         
             
                      i.should be_a_kind_of_response_proxied Jubjub::Pubsub::Item
         
     | 
| 
       256 
252 
     | 
    
         
             
                      i.item_id.should be_a_kind_of String
         
     | 
| 
       257 
     | 
    
         
            -
                      i.data.should  
     | 
| 
      
 253 
     | 
    
         
            +
                      i.data.should be_equivalent_to( item )
         
     | 
| 
       258 
254 
     | 
    
         
             
                    end
         
     | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
       260 
256 
     | 
    
         
             
                  end
         
     | 
| 
       261 
     | 
    
         
            -
             
     | 
| 
      
 257 
     | 
    
         
            +
             
     | 
| 
       262 
258 
     | 
    
         
             
                  describe "with dataform payload" do
         
     | 
| 
       263 
259 
     | 
    
         
             
                    use_vcr_cassette 'pubsub publish with dataform payload', :record => :new_episodes
         
     | 
| 
       264 
     | 
    
         
            -
             
     | 
| 
      
 260 
     | 
    
         
            +
             
     | 
| 
       265 
261 
     | 
    
         
             
                    it "should return a Jubjub::Pubsub::Item" do
         
     | 
| 
       266 
262 
     | 
    
         
             
                      i = @connection.pubsub.publish 'pubsub.theo-template.local', 'node_1', Jubjub::DataForm.new({ :foo => {:type => "boolean", :value => true }})
         
     | 
| 
       267 
263 
     | 
    
         
             
                      i.should be_a_kind_of_response_proxied Jubjub::Pubsub::Item
         
     | 
| 
       268 
264 
     | 
    
         
             
                      i.item_id.should be_a_kind_of String
         
     | 
| 
       269 
     | 
    
         
            -
                      i.data.should  
     | 
| 
      
 265 
     | 
    
         
            +
                      i.data.should be_equivalent_to('<x xmlns="jabber:x:data" type="submit"><field var="foo" type="boolean"><value>true</value></field></x>')
         
     | 
| 
       270 
266 
     | 
    
         
             
                    end
         
     | 
| 
       271 
     | 
    
         
            -
             
     | 
| 
      
 267 
     | 
    
         
            +
             
     | 
| 
       272 
268 
     | 
    
         
             
                  end
         
     | 
| 
       273 
     | 
    
         
            -
             
     | 
| 
      
 269 
     | 
    
         
            +
             
     | 
| 
       274 
270 
     | 
    
         
             
                  after do
         
     | 
| 
       275 
271 
     | 
    
         
             
                    # Clean up the node
         
     | 
| 
       276 
272 
     | 
    
         
             
                    @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_1'
         
     | 
| 
       277 
273 
     | 
    
         
             
                  end
         
     | 
| 
       278 
274 
     | 
    
         | 
| 
       279 
275 
     | 
    
         
             
                end
         
     | 
| 
       280 
     | 
    
         
            -
             
     | 
| 
      
 276 
     | 
    
         
            +
             
     | 
| 
       281 
277 
     | 
    
         
             
                describe "retract" do
         
     | 
| 
       282 
278 
     | 
    
         
             
                  use_vcr_cassette 'pubsub retract', :record => :new_episodes
         
     | 
| 
       283 
     | 
    
         
            -
             
     | 
| 
      
 279 
     | 
    
         
            +
             
     | 
| 
       284 
280 
     | 
    
         
             
                  before do
         
     | 
| 
       285 
281 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_pubsub_retract'
         
     | 
| 
       286 
282 
     | 
    
         
             
                  end
         
     | 
| 
       287 
     | 
    
         
            -
             
     | 
| 
      
 283 
     | 
    
         
            +
             
     | 
| 
       288 
284 
     | 
    
         
             
                  it "should return true when successful" do
         
     | 
| 
       289 
285 
     | 
    
         
             
                    item = @connection.pubsub.publish 'pubsub.theo-template.local', 'node_pubsub_retract', Jubjub::DataForm.new()
         
     | 
| 
       290 
     | 
    
         
            -
             
     | 
| 
      
 286 
     | 
    
         
            +
             
     | 
| 
       291 
287 
     | 
    
         
             
                    @connection.pubsub.retract( 'pubsub.theo-template.local', 'node_pubsub_retract', item.item_id ).should be_true
         
     | 
| 
       292 
288 
     | 
    
         
             
                  end
         
     | 
| 
       293 
     | 
    
         
            -
             
     | 
| 
      
 289 
     | 
    
         
            +
             
     | 
| 
       294 
290 
     | 
    
         
             
                  it "should return false when not successful" do
         
     | 
| 
       295 
     | 
    
         
            -
                    @connection.pubsub.retract( 'pubsub.theo-template.local', 'node_pubsub_retract', "wibble" ).should equal(false) 
     | 
| 
      
 291 
     | 
    
         
            +
                    @connection.pubsub.retract( 'pubsub.theo-template.local', 'node_pubsub_retract', "wibble" ).should equal(false)
         
     | 
| 
       296 
292 
     | 
    
         
             
                  end
         
     | 
| 
       297 
     | 
    
         
            -
             
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
       298 
294 
     | 
    
         
             
                  after do
         
     | 
| 
       299 
295 
     | 
    
         
             
                    # Clean up the node
         
     | 
| 
       300 
296 
     | 
    
         
             
                    @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_pubsub_retract'
         
     | 
| 
       301 
297 
     | 
    
         
             
                  end
         
     | 
| 
       302 
298 
     | 
    
         
             
                end
         
     | 
| 
       303 
     | 
    
         
            -
             
     | 
| 
      
 299 
     | 
    
         
            +
             
     | 
| 
       304 
300 
     | 
    
         
             
                describe "retrieve_items" do
         
     | 
| 
       305 
301 
     | 
    
         
             
                  use_vcr_cassette 'pubsub retrieve items', :record => :new_episodes
         
     | 
| 
       306 
     | 
    
         
            -
             
     | 
| 
      
 302 
     | 
    
         
            +
             
     | 
| 
       307 
303 
     | 
    
         
             
                  before do
         
     | 
| 
       308 
304 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_retrieve_items'
         
     | 
| 
       309 
305 
     | 
    
         
             
                    @connection.pubsub.publish 'pubsub.theo-template.local', 'node_retrieve_items', Jubjub::DataForm.new(:bar => {:type => :boolean, :value => true}), 'efg'
         
     | 
| 
       310 
306 
     | 
    
         
             
                    @connection.pubsub.publish 'pubsub.theo-template.local', 'node_retrieve_items', Jubjub::DataForm.new(:foo => {:type => :boolean, :value => false}), 'abc'
         
     | 
| 
       311 
307 
     | 
    
         
             
                  end
         
     | 
| 
       312 
     | 
    
         
            -
             
     | 
| 
      
 308 
     | 
    
         
            +
             
     | 
| 
       313 
309 
     | 
    
         
             
                  it "should return array of Pubsub::Item when successful" do
         
     | 
| 
       314 
310 
     | 
    
         
             
                    expected = [
         
     | 
| 
       315 
     | 
    
         
            -
                      Jubjub::Pubsub::Item.new( 'pubsub.theo-template.local', 'node_retrieve_items', 'abc', "<x xmlns=\"jabber:x:data\" type=\"submit\">\n          <field var=\"foo\">\n            <value>false</value>\n          </field>\n        </x>", @connection ),
         
     | 
| 
       316 
     | 
    
         
            -
                      Jubjub::Pubsub::Item.new( 'pubsub.theo-template.local', 'node_retrieve_items', 'efg', "<x xmlns=\"jabber:x:data\" type=\"submit\">\n          <field var=\"bar\">\n            <value>true</value>\n          </field>\n        </x>", @connection )
         
     | 
| 
      
 311 
     | 
    
         
            +
                      Jubjub::Pubsub::Item.new( 'pubsub.theo-template.local', 'node_retrieve_items', 'abc', "<x xmlns=\"jabber:x:data\" type=\"submit\">\n          <field type=\"boolean\" var=\"foo\">\n            <value>false</value>\n          </field>\n        </x>", @connection ),
         
     | 
| 
      
 312 
     | 
    
         
            +
                      Jubjub::Pubsub::Item.new( 'pubsub.theo-template.local', 'node_retrieve_items', 'efg', "<x xmlns=\"jabber:x:data\" type=\"submit\">\n          <field type=\"boolean\" var=\"bar\">\n            <value>true</value>\n          </field>\n        </x>", @connection )
         
     | 
| 
       317 
313 
     | 
    
         
             
                    ]
         
     | 
| 
       318 
     | 
    
         
            -
             
     | 
| 
      
 314 
     | 
    
         
            +
             
     | 
| 
       319 
315 
     | 
    
         
             
                    @connection.pubsub.retrieve_items( 'pubsub.theo-template.local', 'node_retrieve_items' ).should == expected
         
     | 
| 
       320 
316 
     | 
    
         
             
                  end
         
     | 
| 
       321 
     | 
    
         
            -
             
     | 
| 
      
 317 
     | 
    
         
            +
             
     | 
| 
       322 
318 
     | 
    
         
             
                  it "should return empty array when not successful" do
         
     | 
| 
       323 
319 
     | 
    
         
             
                    @connection.pubsub.retrieve_items( 'pubsub.theo-template.local', 'node_retrieve_items_wibble' ).should == []
         
     | 
| 
       324 
320 
     | 
    
         
             
                  end
         
     | 
| 
       325 
     | 
    
         
            -
             
     | 
| 
      
 321 
     | 
    
         
            +
             
     | 
| 
       326 
322 
     | 
    
         
             
                  after do
         
     | 
| 
       327 
323 
     | 
    
         
             
                    # Clean up the node
         
     | 
| 
       328 
324 
     | 
    
         
             
                    @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_retrieve_items'
         
     | 
| 
       329 
325 
     | 
    
         
             
                  end
         
     | 
| 
       330 
326 
     | 
    
         
             
                end
         
     | 
| 
       331 
     | 
    
         
            -
             
     | 
| 
      
 327 
     | 
    
         
            +
             
     | 
| 
       332 
328 
     | 
    
         
             
                describe "retrieve_affiliations" do
         
     | 
| 
       333 
329 
     | 
    
         
             
                  use_vcr_cassette 'pubsub retrieve affiliations', :record => :new_episodes
         
     | 
| 
       334 
     | 
    
         
            -
             
     | 
| 
      
 330 
     | 
    
         
            +
             
     | 
| 
       335 
331 
     | 
    
         
             
                  it "should return array of Pubsub::Affiliation when successful" do
         
     | 
| 
       336 
332 
     | 
    
         
             
                    @connection.pubsub.create 'pubsub.theo-template.local', 'node_retrieve_affiliations'
         
     | 
| 
       337 
     | 
    
         
            -
             
     | 
| 
      
 333 
     | 
    
         
            +
             
     | 
| 
       338 
334 
     | 
    
         
             
                    expected = [
         
     | 
| 
       339 
335 
     | 
    
         
             
                      Jubjub::Pubsub::Affiliation.new(
         
     | 
| 
       340 
336 
     | 
    
         
             
                        'pubsub.theo-template.local',
         
     | 
| 
       341 
337 
     | 
    
         
             
                        'node_retrieve_affiliations',
         
     | 
| 
       342 
338 
     | 
    
         
             
                        Jubjub::Jid.new('theozaurus@theo-template.local'),
         
     | 
| 
       343 
339 
     | 
    
         
             
                        'owner',
         
     | 
| 
       344 
     | 
    
         
            -
                        @connection 
     | 
| 
      
 340 
     | 
    
         
            +
                        @connection
         
     | 
| 
       345 
341 
     | 
    
         
             
                      )
         
     | 
| 
       346 
342 
     | 
    
         
             
                    ]
         
     | 
| 
       347 
     | 
    
         
            -
             
     | 
| 
      
 343 
     | 
    
         
            +
             
     | 
| 
       348 
344 
     | 
    
         
             
                    @connection.pubsub.retrieve_affiliations( 'pubsub.theo-template.local', 'node_retrieve_affiliations' ).should == expected
         
     | 
| 
       349 
345 
     | 
    
         | 
| 
       350 
346 
     | 
    
         
             
                    # Clean up the node
         
     | 
| 
       351 
347 
     | 
    
         
             
                    @connection.pubsub.destroy 'pubsub.theo-template.local', 'node_retrieve_affiliations'
         
     | 
| 
       352 
348 
     | 
    
         
             
                  end
         
     | 
| 
       353 
     | 
    
         
            -
             
     | 
| 
      
 349 
     | 
    
         
            +
             
     | 
| 
       354 
350 
     | 
    
         
             
                  it "should return empty array when not successful" do
         
     | 
| 
       355 
351 
     | 
    
         
             
                    @connection.pubsub.retrieve_affiliations( 'pubsub.theo-template.local', 'made-up' ).should == []
         
     | 
| 
       356 
352 
     | 
    
         
             
                  end
         
     | 
| 
       357 
353 
     | 
    
         
             
                end
         
     | 
| 
       358 
     | 
    
         
            -
             
     | 
| 
      
 354 
     | 
    
         
            +
             
     | 
| 
       359 
355 
     | 
    
         
             
                describe "modify_affiliations" do
         
     | 
| 
       360 
356 
     | 
    
         
             
                  use_vcr_cassette 'pubsub modify affiliations', :record => :new_episodes
         
     | 
| 
       361 
     | 
    
         
            -
             
     | 
| 
      
 357 
     | 
    
         
            +
             
     | 
| 
       362 
358 
     | 
    
         
             
                  it "should return true when successful" do
         
     | 
| 
       363 
359 
     | 
    
         
             
                    pubsub = 'pubsub.theo-template.local'
         
     | 
| 
       364 
360 
     | 
    
         
             
                    node = 'node_modify_affiliations_1'
         
     | 
| 
       365 
361 
     | 
    
         
             
                    @connection.pubsub.create pubsub, node
         
     | 
| 
       366 
     | 
    
         
            -
             
     | 
| 
      
 362 
     | 
    
         
            +
             
     | 
| 
       367 
363 
     | 
    
         
             
                    affiliation = Jubjub::Pubsub::Affiliation.new pubsub, node, 'theozaurus@theo-template.local', 'owner', @connection
         
     | 
| 
       368 
364 
     | 
    
         
             
                    @connection.pubsub.modify_affiliations( pubsub, node, affiliation).should equal(true)
         
     | 
| 
       369 
     | 
    
         
            -
             
     | 
| 
      
 365 
     | 
    
         
            +
             
     | 
| 
       370 
366 
     | 
    
         
             
                    @connection.pubsub.destroy pubsub, node
         
     | 
| 
       371 
367 
     | 
    
         
             
                  end
         
     | 
| 
       372 
     | 
    
         
            -
             
     | 
| 
      
 368 
     | 
    
         
            +
             
     | 
| 
       373 
369 
     | 
    
         
             
                  it "should allow affiliations to be specified as an array" do
         
     | 
| 
       374 
370 
     | 
    
         
             
                    pubsub = 'pubsub.theo-template.local'
         
     | 
| 
       375 
371 
     | 
    
         
             
                    node = 'node_modify_affiliations_2'
         
     | 
| 
       376 
372 
     | 
    
         
             
                    @connection.pubsub.create pubsub, node
         
     | 
| 
       377 
     | 
    
         
            -
             
     | 
| 
      
 373 
     | 
    
         
            +
             
     | 
| 
       378 
374 
     | 
    
         
             
                    affiliation_1 = Jubjub::Pubsub::Affiliation.new pubsub, node, 'theozaurus@theo-template.local','owner', @connection
         
     | 
| 
       379 
375 
     | 
    
         
             
                    affiliation_2 = Jubjub::Pubsub::Affiliation.new pubsub, node, 'trex@theo-template.local', 'publisher', @connection
         
     | 
| 
       380 
376 
     | 
    
         
             
                    @connection.pubsub.modify_affiliations pubsub, node, [affiliation_1, affiliation_2]
         
     | 
| 
       381 
     | 
    
         
            -
             
     | 
| 
      
 377 
     | 
    
         
            +
             
     | 
| 
       382 
378 
     | 
    
         
             
                    @connection.pubsub.destroy pubsub, node
         
     | 
| 
       383 
379 
     | 
    
         
             
                  end
         
     | 
| 
       384 
     | 
    
         
            -
             
     | 
| 
      
 380 
     | 
    
         
            +
             
     | 
| 
       385 
381 
     | 
    
         
             
                  it "should allow affiliations to be specified as arguments" do
         
     | 
| 
       386 
382 
     | 
    
         
             
                    pubsub = 'pubsub.theo-template.local'
         
     | 
| 
       387 
383 
     | 
    
         
             
                    node = 'node_modify_affiliations_3'
         
     | 
| 
       388 
384 
     | 
    
         
             
                    @connection.pubsub.create pubsub, node
         
     | 
| 
       389 
     | 
    
         
            -
             
     | 
| 
      
 385 
     | 
    
         
            +
             
     | 
| 
       390 
386 
     | 
    
         
             
                    affiliation_1 = Jubjub::Pubsub::Affiliation.new pubsub, node, 'theozaurus@theo-template.local', 'owner', @connection
         
     | 
| 
       391 
387 
     | 
    
         
             
                    affiliation_2 = Jubjub::Pubsub::Affiliation.new pubsub, node, 'trex@theo-template.local', 'publisher', @connection
         
     | 
| 
       392 
388 
     | 
    
         
             
                    @connection.pubsub.modify_affiliations pubsub, node, affiliation_1, affiliation_2
         
     | 
| 
       393 
     | 
    
         
            -
             
     | 
| 
      
 389 
     | 
    
         
            +
             
     | 
| 
       394 
390 
     | 
    
         
             
                    @connection.pubsub.destroy pubsub, node
         
     | 
| 
       395 
391 
     | 
    
         
             
                  end
         
     | 
| 
       396 
     | 
    
         
            -
             
     | 
| 
      
 392 
     | 
    
         
            +
             
     | 
| 
       397 
393 
     | 
    
         
             
                  it "should return false if unsuccessful" do
         
     | 
| 
       398 
394 
     | 
    
         
             
                    pubsub = 'pubsub.theo-template.local'
         
     | 
| 
       399 
395 
     | 
    
         
             
                    node = 'node_modify_affiliations_4'
         
     | 
| 
       400 
396 
     | 
    
         
             
                    @connection.pubsub.create pubsub, node
         
     | 
| 
       401 
     | 
    
         
            -
             
     | 
| 
      
 397 
     | 
    
         
            +
             
     | 
| 
       402 
398 
     | 
    
         
             
                    affiliation = Jubjub::Pubsub::Affiliation.new pubsub, node, 'theozaurus@theo-template.local', 'WIBBLE', @connection
         
     | 
| 
       403 
399 
     | 
    
         
             
                    @connection.pubsub.modify_affiliations( pubsub, node, affiliation ).should equal(false)
         
     | 
| 
       404 
     | 
    
         
            -
             
     | 
| 
      
 400 
     | 
    
         
            +
             
     | 
| 
       405 
401 
     | 
    
         
             
                    @connection.pubsub.destroy pubsub, node
         
     | 
| 
       406 
402 
     | 
    
         
             
                  end
         
     | 
| 
       407 
403 
     | 
    
         
             
                end
         
     | 
| 
       408 
     | 
    
         
            -
             
     | 
| 
      
 404 
     | 
    
         
            +
             
     | 
| 
       409 
405 
     | 
    
         
             
              end
         
     | 
| 
       410 
     | 
    
         
            -
             
     | 
| 
       411 
     | 
    
         
            -
            end
         
     | 
| 
      
 406 
     | 
    
         
            +
             
     | 
| 
      
 407 
     | 
    
         
            +
            end
         
     |