blather 0.6.2 → 0.7.0
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/.rspec +3 -0
- data/.travis.yml +1 -8
- data/CHANGELOG.md +230 -0
- data/Guardfile +4 -4
- data/README.md +2 -8
- data/Rakefile +14 -27
- data/blather.gemspec +8 -18
- data/lib/blather.rb +1 -0
- data/lib/blather/client/client.rb +8 -0
- data/lib/blather/roster.rb +7 -0
- data/lib/blather/stanza/iq/roster.rb +1 -1
- data/lib/blather/stanza/message/muc_user.rb +2 -0
- data/lib/blather/stanza/muc/muc_user_base.rb +4 -3
- data/lib/blather/stanza/presence.rb +12 -14
- data/lib/blather/stanza/presence/c.rb +58 -62
- data/lib/blather/stanza/presence/muc.rb +14 -10
- data/lib/blather/stanza/presence/muc_user.rb +47 -36
- data/lib/blather/stanza/presence/status.rb +106 -101
- data/lib/blather/stanza/presence/subscription.rb +59 -60
- data/lib/blather/stream.rb +1 -3
- data/lib/blather/stream/features/resource.rb +0 -1
- data/lib/blather/version.rb +1 -2
- data/lib/blather/xmpp_node.rb +24 -3
- data/spec/blather/client/client_spec.rb +64 -64
- data/spec/blather/client/dsl/pubsub_spec.rb +127 -127
- data/spec/blather/client/dsl_spec.rb +11 -11
- data/spec/blather/errors/sasl_error_spec.rb +3 -3
- data/spec/blather/errors/stanza_error_spec.rb +26 -26
- data/spec/blather/errors/stream_error_spec.rb +22 -22
- data/spec/blather/errors_spec.rb +7 -7
- data/spec/blather/file_transfer_spec.rb +16 -18
- data/spec/blather/jid_spec.rb +29 -29
- data/spec/blather/roster_item_spec.rb +18 -18
- data/spec/blather/roster_spec.rb +18 -18
- data/spec/blather/stanza/discos/disco_info_spec.rb +56 -57
- data/spec/blather/stanza/discos/disco_items_spec.rb +33 -33
- data/spec/blather/stanza/iq/command_spec.rb +57 -57
- data/spec/blather/stanza/iq/ibb_spec.rb +27 -39
- data/spec/blather/stanza/iq/ping_spec.rb +13 -9
- data/spec/blather/stanza/iq/query_spec.rb +16 -16
- data/spec/blather/stanza/iq/roster_spec.rb +29 -30
- data/spec/blather/stanza/iq/s5b_spec.rb +10 -13
- data/spec/blather/stanza/iq/si_spec.rb +20 -23
- data/spec/blather/stanza/iq/vcard_spec.rb +22 -25
- data/spec/blather/stanza/iq_spec.rb +12 -12
- data/spec/blather/stanza/message/muc_user_spec.rb +36 -36
- data/spec/blather/stanza/message_spec.rb +56 -56
- data/spec/blather/stanza/presence/c_spec.rb +17 -7
- data/spec/blather/stanza/presence/muc_spec.rb +8 -8
- data/spec/blather/stanza/presence/muc_user_spec.rb +23 -23
- data/spec/blather/stanza/presence/status_spec.rb +42 -30
- data/spec/blather/stanza/presence/subscription_spec.rb +22 -23
- data/spec/blather/stanza/presence_spec.rb +72 -34
- data/spec/blather/stanza/pubsub/affiliations_spec.rb +12 -12
- data/spec/blather/stanza/pubsub/create_spec.rb +10 -10
- data/spec/blather/stanza/pubsub/event_spec.rb +31 -31
- data/spec/blather/stanza/pubsub/items_spec.rb +21 -21
- data/spec/blather/stanza/pubsub/publish_spec.rb +21 -21
- data/spec/blather/stanza/pubsub/retract_spec.rb +20 -20
- data/spec/blather/stanza/pubsub/subscribe_spec.rb +17 -17
- data/spec/blather/stanza/pubsub/subscription_spec.rb +28 -28
- data/spec/blather/stanza/pubsub/subscriptions_spec.rb +11 -11
- data/spec/blather/stanza/pubsub/unsubscribe_spec.rb +22 -22
- data/spec/blather/stanza/pubsub_owner/delete_spec.rb +9 -9
- data/spec/blather/stanza/pubsub_owner/purge_spec.rb +9 -9
- data/spec/blather/stanza/pubsub_owner_spec.rb +6 -6
- data/spec/blather/stanza/pubsub_spec.rb +16 -16
- data/spec/blather/stanza/x_spec.rb +53 -53
- data/spec/blather/stanza_spec.rb +39 -39
- data/spec/blather/stream/client_spec.rb +133 -133
- data/spec/blather/stream/component_spec.rb +7 -7
- data/spec/blather/stream/parser_spec.rb +24 -24
- data/spec/blather/stream/ssl_spec.rb +7 -7
- data/spec/blather/xmpp_node_spec.rb +17 -7
- data/spec/blather_spec.rb +4 -4
- data/spec/spec_helper.rb +6 -54
- metadata +53 -68
- data/CHANGELOG +0 -220
    
        data/spec/blather/stanza_spec.rb
    CHANGED
    
    | @@ -2,42 +2,42 @@ require 'spec_helper' | |
| 2 2 |  | 
| 3 3 | 
             
            describe Blather::Stanza do
         | 
| 4 4 | 
             
              it 'provides .next_id helper for generating new IDs' do
         | 
| 5 | 
            -
                proc { Blather::Stanza.next_id }. | 
| 5 | 
            +
                proc { Blather::Stanza.next_id }.should change Blather::Stanza, :next_id
         | 
| 6 6 | 
             
              end
         | 
| 7 7 |  | 
| 8 8 | 
             
              it 'provides a handler registration mechanism' do
         | 
| 9 9 | 
             
                class Registration < Blather::Stanza; register :handler_test, :handler, 'test:namespace'; end
         | 
| 10 | 
            -
                Registration.handler_hierarchy. | 
| 11 | 
            -
                Blather::Stanza.handler_list. | 
| 10 | 
            +
                Registration.handler_hierarchy.should include :handler_test
         | 
| 11 | 
            +
                Blather::Stanza.handler_list.should include :handler_test
         | 
| 12 12 | 
             
              end
         | 
| 13 13 |  | 
| 14 14 | 
             
              it 'can register based on handler' do
         | 
| 15 15 | 
             
                class RegisterHandler < Blather::Stanza; register :register_handler; end
         | 
| 16 | 
            -
                Blather::Stanza.class_from_registration(:register_handler, nil). | 
| 16 | 
            +
                Blather::Stanza.class_from_registration(:register_handler, nil).should == RegisterHandler
         | 
| 17 17 | 
             
              end
         | 
| 18 18 |  | 
| 19 19 | 
             
              it 'can register based on given name' do
         | 
| 20 20 | 
             
                class RegisterName < Blather::Stanza; register :handler, :registered_name; end
         | 
| 21 | 
            -
                Blather::Stanza.class_from_registration(:registered_name, nil). | 
| 21 | 
            +
                Blather::Stanza.class_from_registration(:registered_name, nil).should == RegisterName
         | 
| 22 22 | 
             
              end
         | 
| 23 23 |  | 
| 24 24 | 
             
              it 'can register subclass handlers' do
         | 
| 25 25 | 
             
                class SuperClassRegister < Blather::Stanza; register :super_class; end
         | 
| 26 26 | 
             
                class SubClassRegister < SuperClassRegister; register :sub_class; end
         | 
| 27 | 
            -
                SuperClassRegister.handler_hierarchy. | 
| 28 | 
            -
                SubClassRegister.handler_hierarchy. | 
| 27 | 
            +
                SuperClassRegister.handler_hierarchy.should_not include :sub_class
         | 
| 28 | 
            +
                SubClassRegister.handler_hierarchy.should include :super_class
         | 
| 29 29 | 
             
              end
         | 
| 30 30 |  | 
| 31 31 | 
             
              it 'can import a node' do
         | 
| 32 32 | 
             
                s = Blather::Stanza.import Blather::XMPPNode.new('foo')
         | 
| 33 | 
            -
                s.element_name. | 
| 33 | 
            +
                s.element_name.should == 'foo'
         | 
| 34 34 | 
             
              end
         | 
| 35 35 |  | 
| 36 36 | 
             
              it 'provides an #error? helper' do
         | 
| 37 37 | 
             
                s = Blather::Stanza.new('message')
         | 
| 38 | 
            -
                s.error?. | 
| 38 | 
            +
                s.error?.should == false
         | 
| 39 39 | 
             
                s.type = :error
         | 
| 40 | 
            -
                s.error?. | 
| 40 | 
            +
                s.error?.should == true
         | 
| 41 41 | 
             
              end
         | 
| 42 42 |  | 
| 43 43 | 
             
              it 'will generate a reply' do
         | 
| @@ -46,9 +46,9 @@ describe Blather::Stanza do | |
| 46 46 | 
             
                s.to = t = Blather::JID.new('d@n/r')
         | 
| 47 47 |  | 
| 48 48 | 
             
                r = s.reply
         | 
| 49 | 
            -
                r.object_id. | 
| 50 | 
            -
                r.from. | 
| 51 | 
            -
                r.to. | 
| 49 | 
            +
                r.object_id.should_not equal s.object_id
         | 
| 50 | 
            +
                r.from.should == t
         | 
| 51 | 
            +
                r.to.should == f
         | 
| 52 52 | 
             
              end
         | 
| 53 53 |  | 
| 54 54 | 
             
              it 'convert to a reply' do
         | 
| @@ -57,9 +57,9 @@ describe Blather::Stanza do | |
| 57 57 | 
             
                s.to = t = Blather::JID.new('d@n/r')
         | 
| 58 58 |  | 
| 59 59 | 
             
                r = s.reply!
         | 
| 60 | 
            -
                r.object_id. | 
| 61 | 
            -
                r.from. | 
| 62 | 
            -
                r.to. | 
| 60 | 
            +
                r.object_id.should == s.object_id
         | 
| 61 | 
            +
                r.from.should == t
         | 
| 62 | 
            +
                r.to.should == f
         | 
| 63 63 | 
             
              end
         | 
| 64 64 |  | 
| 65 65 | 
             
              it 'does not remove the body when replying' do
         | 
| @@ -68,7 +68,7 @@ describe Blather::Stanza do | |
| 68 68 | 
             
                s.to = t = Blather::JID.new('d@n/r')
         | 
| 69 69 | 
             
                s << Blather::XMPPNode.new('query', s.document)
         | 
| 70 70 | 
             
                r = s.reply
         | 
| 71 | 
            -
                r.children.empty?. | 
| 71 | 
            +
                r.children.empty?.should == false
         | 
| 72 72 | 
             
              end
         | 
| 73 73 |  | 
| 74 74 | 
             
              it 'removes the body when replying if we ask to remove it' do
         | 
| @@ -77,58 +77,58 @@ describe Blather::Stanza do | |
| 77 77 | 
             
                s.to = t = Blather::JID.new('d@n/r')
         | 
| 78 78 | 
             
                s << Blather::XMPPNode.new('query', s.document)
         | 
| 79 79 | 
             
                r = s.reply :remove_children => true
         | 
| 80 | 
            -
                r.children.empty?. | 
| 80 | 
            +
                r.children.empty?.should == true
         | 
| 81 81 | 
             
              end
         | 
| 82 82 |  | 
| 83 83 | 
             
              it 'provides "attr_accessor" for id' do
         | 
| 84 84 | 
             
                s = Blather::Stanza.new('message')
         | 
| 85 | 
            -
                s.id. | 
| 86 | 
            -
                s[:id]. | 
| 85 | 
            +
                s.id.should be_nil
         | 
| 86 | 
            +
                s[:id].should be_nil
         | 
| 87 87 |  | 
| 88 88 | 
             
                s.id = '123'
         | 
| 89 | 
            -
                s.id. | 
| 90 | 
            -
                s[:id]. | 
| 89 | 
            +
                s.id.should == '123'
         | 
| 90 | 
            +
                s[:id].should == '123'
         | 
| 91 91 | 
             
              end
         | 
| 92 92 |  | 
| 93 93 | 
             
              it 'provides "attr_accessor" for to' do
         | 
| 94 94 | 
             
                s = Blather::Stanza.new('message')
         | 
| 95 | 
            -
                s.to. | 
| 96 | 
            -
                s[:to]. | 
| 95 | 
            +
                s.to.should be_nil
         | 
| 96 | 
            +
                s[:to].should be_nil
         | 
| 97 97 |  | 
| 98 98 | 
             
                s.to = Blather::JID.new('n@d/r')
         | 
| 99 | 
            -
                s.to. | 
| 100 | 
            -
                s.to. | 
| 99 | 
            +
                s.to.should_not be_nil
         | 
| 100 | 
            +
                s.to.should be_kind_of Blather::JID
         | 
| 101 101 |  | 
| 102 | 
            -
                s[:to]. | 
| 103 | 
            -
                s[:to]. | 
| 102 | 
            +
                s[:to].should_not be_nil
         | 
| 103 | 
            +
                s[:to].should == 'n@d/r'
         | 
| 104 104 | 
             
              end
         | 
| 105 105 |  | 
| 106 106 | 
             
              it 'provides "attr_accessor" for from' do
         | 
| 107 107 | 
             
                s = Blather::Stanza.new('message')
         | 
| 108 | 
            -
                s.from. | 
| 109 | 
            -
                s[:from]. | 
| 108 | 
            +
                s.from.should be_nil
         | 
| 109 | 
            +
                s[:from].should be_nil
         | 
| 110 110 |  | 
| 111 111 | 
             
                s.from = Blather::JID.new('n@d/r')
         | 
| 112 | 
            -
                s.from. | 
| 113 | 
            -
                s.from. | 
| 112 | 
            +
                s.from.should_not be_nil
         | 
| 113 | 
            +
                s.from.should be_kind_of Blather::JID
         | 
| 114 114 |  | 
| 115 | 
            -
                s[:from]. | 
| 116 | 
            -
                s[:from]. | 
| 115 | 
            +
                s[:from].should_not be_nil
         | 
| 116 | 
            +
                s[:from].should == 'n@d/r'
         | 
| 117 117 | 
             
              end
         | 
| 118 118 |  | 
| 119 119 | 
             
              it 'provides "attr_accessor" for type' do
         | 
| 120 120 | 
             
                s = Blather::Stanza.new('message')
         | 
| 121 | 
            -
                s.type. | 
| 122 | 
            -
                s[:type]. | 
| 121 | 
            +
                s.type.should be_nil
         | 
| 122 | 
            +
                s[:type].should be_nil
         | 
| 123 123 |  | 
| 124 124 | 
             
                s.type = 'testing'
         | 
| 125 | 
            -
                s.type. | 
| 126 | 
            -
                s[:type]. | 
| 125 | 
            +
                s.type.should_not be_nil
         | 
| 126 | 
            +
                s[:type].should_not be_nil
         | 
| 127 127 | 
             
              end
         | 
| 128 128 |  | 
| 129 129 | 
             
              it 'can be converted into an error by error name' do
         | 
| 130 130 | 
             
                s = Blather::Stanza.new('message')
         | 
| 131 131 | 
             
                err = s.as_error 'internal-server-error', 'cancel'
         | 
| 132 | 
            -
                err.name. | 
| 132 | 
            +
                err.name.should == :internal_server_error
         | 
| 133 133 | 
             
              end
         | 
| 134 134 | 
             
            end
         | 
| @@ -35,11 +35,11 @@ describe Blather::Stream::Client do | |
| 35 35 | 
             
                client = mock()
         | 
| 36 36 | 
             
                params = [client, 'n@d/r', 'pass', 'host', 1234]
         | 
| 37 37 | 
             
                EM.expects(:connect).with do |*parms|
         | 
| 38 | 
            -
                  parms[0]. | 
| 39 | 
            -
                  parms[1]. | 
| 40 | 
            -
                  parms[3]. | 
| 41 | 
            -
                  parms[5]. | 
| 42 | 
            -
                  parms[4]. | 
| 38 | 
            +
                  parms[0].should == 'host'
         | 
| 39 | 
            +
                  parms[1].should == 1234
         | 
| 40 | 
            +
                  parms[3].should == client
         | 
| 41 | 
            +
                  parms[5].should == 'pass'
         | 
| 42 | 
            +
                  parms[4].should == Blather::JID.new('n@d/r')
         | 
| 43 43 | 
             
                end
         | 
| 44 44 |  | 
| 45 45 | 
             
                Blather::Stream::Client.start *params
         | 
| @@ -55,11 +55,11 @@ describe Blather::Stream::Client do | |
| 55 55 |  | 
| 56 56 | 
             
                client = Class.new
         | 
| 57 57 | 
             
                EM.expects(:connect).with do |*parms|
         | 
| 58 | 
            -
                  parms[0]. | 
| 59 | 
            -
                  parms[1]. | 
| 60 | 
            -
                  parms[3]. | 
| 61 | 
            -
                  parms[5]. | 
| 62 | 
            -
                  parms[4]. | 
| 58 | 
            +
                  parms[0].should == 'd'
         | 
| 59 | 
            +
                  parms[1].should == 5222
         | 
| 60 | 
            +
                  parms[3].should == client
         | 
| 61 | 
            +
                  parms[5].should == 'pass'
         | 
| 62 | 
            +
                  parms[4].should == Blather::JID.new('n@d/r')
         | 
| 63 63 | 
             
                end
         | 
| 64 64 |  | 
| 65 65 | 
             
                Blather::Stream::Client.start client, 'n@d/r', 'pass'
         | 
| @@ -73,11 +73,11 @@ describe Blather::Stream::Client do | |
| 73 73 | 
             
                client = Class.new
         | 
| 74 74 | 
             
                EM.expects(:connect).with do |*parms|
         | 
| 75 75 | 
             
                  raise Blather::Stream::NoConnection if parms[0] == 'd'
         | 
| 76 | 
            -
                  parms[0]. | 
| 77 | 
            -
                  parms[1]. | 
| 78 | 
            -
                  parms[3]. | 
| 79 | 
            -
                  parms[5]. | 
| 80 | 
            -
                  parms[4]. | 
| 76 | 
            +
                  parms[0].should == 'g'
         | 
| 77 | 
            +
                  parms[1].should == 1234
         | 
| 78 | 
            +
                  parms[3].should == client
         | 
| 79 | 
            +
                  parms[5].should == 'pass'
         | 
| 80 | 
            +
                  parms[4].should == Blather::JID.new('n@d/r')
         | 
| 81 81 | 
             
                end
         | 
| 82 82 | 
             
                Blather::Stream::Client.start client, 'n@d/r', 'pass'
         | 
| 83 83 | 
             
              end
         | 
| @@ -89,11 +89,11 @@ describe Blather::Stream::Client do | |
| 89 89 |  | 
| 90 90 | 
             
                client = Class.new
         | 
| 91 91 | 
             
                EM.expects(:connect).with do |*parms|
         | 
| 92 | 
            -
                  parms[0]. | 
| 93 | 
            -
                  parms[1]. | 
| 94 | 
            -
                  parms[3]. | 
| 95 | 
            -
                  parms[5]. | 
| 96 | 
            -
                  parms[4]. | 
| 92 | 
            +
                  parms[0].should == 'd'
         | 
| 93 | 
            +
                  parms[1].should == 5222
         | 
| 94 | 
            +
                  parms[3].should == client
         | 
| 95 | 
            +
                  parms[5].should == 'pass'
         | 
| 96 | 
            +
                  parms[4].should == Blather::JID.new('n@d/r')
         | 
| 97 97 | 
             
                end
         | 
| 98 98 | 
             
                Blather::Stream::Client.start client, 'n@d/r', 'pass'
         | 
| 99 99 | 
             
              end
         | 
| @@ -103,11 +103,11 @@ describe Blather::Stream::Client do | |
| 103 103 | 
             
                client = Class.new
         | 
| 104 104 | 
             
                params = [client, 'n@d/r', 'pass', nil, 5222]
         | 
| 105 105 | 
             
                EM.expects(:connect).with do |*parms|
         | 
| 106 | 
            -
                  parms[0]. | 
| 107 | 
            -
                  parms[1]. | 
| 108 | 
            -
                  parms[3]. | 
| 109 | 
            -
                  parms[5]. | 
| 110 | 
            -
                  parms[4]. | 
| 106 | 
            +
                  parms[0].should == 'd'
         | 
| 107 | 
            +
                  parms[1].should == 5222
         | 
| 108 | 
            +
                  parms[3].should == client
         | 
| 109 | 
            +
                  parms[5].should == 'pass'
         | 
| 110 | 
            +
                  parms[4].should == Blather::JID.new('n@d/r')
         | 
| 111 111 | 
             
                end
         | 
| 112 112 |  | 
| 113 113 | 
             
                Blather::Stream::Client.start client, 'n@d/r', 'pass'
         | 
| @@ -120,22 +120,22 @@ describe Blather::Stream::Client do | |
| 120 120 |  | 
| 121 121 | 
             
                    Blather::Stream::Client.start @client, @jid || Blather::JID.new('n@d/r'), 'pass', '127.0.0.1', 50000 - rand(1000)
         | 
| 122 122 | 
             
                  }
         | 
| 123 | 
            -
                end. | 
| 123 | 
            +
                end.should raise_error Blather::Stream::ConnectionFailed
         | 
| 124 124 | 
             
              end
         | 
| 125 125 |  | 
| 126 126 | 
             
              it 'starts the stream once the connection is complete' do
         | 
| 127 | 
            -
                mocked_server(1) { |val, _| EM.stop; val. | 
| 127 | 
            +
                mocked_server(1) { |val, _| EM.stop; val.should match(/stream:stream/) }
         | 
| 128 128 | 
             
              end
         | 
| 129 129 |  | 
| 130 130 | 
             
              it 'sends stanzas to the client when the stream is ready' do
         | 
| 131 131 | 
             
                @client = mock()
         | 
| 132 132 | 
             
                @client.expects(:receive_data).with do |n|
         | 
| 133 133 | 
             
                  EM.stop
         | 
| 134 | 
            -
                  n. | 
| 134 | 
            +
                  n.should be_kind_of Blather::Stanza::Message
         | 
| 135 135 | 
             
                end
         | 
| 136 136 |  | 
| 137 137 | 
             
                mocked_server(1) do |val, server|
         | 
| 138 | 
            -
                  val. | 
| 138 | 
            +
                  val.should match(/stream:stream/)
         | 
| 139 139 | 
             
                  server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 140 140 | 
             
                  server.send_data "<message to='a@b/c' from='d@e/f' type='chat' xml:lang='en'><body>Message!</body></message>"
         | 
| 141 141 | 
             
                end
         | 
| @@ -151,13 +151,13 @@ describe Blather::Stream::Client do | |
| 151 151 | 
             
                    started = true
         | 
| 152 152 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 153 153 | 
             
                    server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
         | 
| 154 | 
            -
                    val. | 
| 154 | 
            +
                    val.should match(/stream:stream/)
         | 
| 155 155 |  | 
| 156 156 | 
             
                  else
         | 
| 157 157 | 
             
                    EM.stop
         | 
| 158 | 
            -
                    @stream.stopped?. | 
| 158 | 
            +
                    @stream.stopped?.should == false
         | 
| 159 159 | 
             
                    @stream.unbind
         | 
| 160 | 
            -
                    @stream.stopped?. | 
| 160 | 
            +
                    @stream.stopped?.should == true
         | 
| 161 161 |  | 
| 162 162 | 
             
                  end
         | 
| 163 163 | 
             
                end
         | 
| @@ -168,7 +168,7 @@ describe Blather::Stream::Client do | |
| 168 168 | 
             
                @client = mock()
         | 
| 169 169 | 
             
                @client.expects(:receive_data).with do |n|
         | 
| 170 170 | 
             
                  EM.stop
         | 
| 171 | 
            -
                  state. | 
| 171 | 
            +
                  state.should ==(:negotiated) && @stream.negotiating?.should ==(false)
         | 
| 172 172 | 
             
                end
         | 
| 173 173 |  | 
| 174 174 | 
             
                mocked_server(2) do |val, server|
         | 
| @@ -181,7 +181,7 @@ describe Blather::Stream::Client do | |
| 181 181 |  | 
| 182 182 | 
             
                  when :started
         | 
| 183 183 | 
             
                    state = :negotiated
         | 
| 184 | 
            -
                    @stream.negotiating?. | 
| 184 | 
            +
                    @stream.negotiating?.should == true
         | 
| 185 185 | 
             
                    server.send_data "<iq from='d' type='result' id='#{val[/id="([^"]+)"/,1]}' />"
         | 
| 186 186 | 
             
                    server.send_data "<message to='a@b/c' from='d@e/f' type='chat' xml:lang='en'><body>Message!</body></message>"
         | 
| 187 187 | 
             
                    true
         | 
| @@ -202,17 +202,17 @@ describe Blather::Stream::Client do | |
| 202 202 | 
             
                    state = :started
         | 
| 203 203 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>"
         | 
| 204 204 | 
             
                    server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
         | 
| 205 | 
            -
                    val. | 
| 205 | 
            +
                    val.should match(/stream:stream/)
         | 
| 206 206 |  | 
| 207 207 | 
             
                  when :started
         | 
| 208 208 | 
             
                    state = :stopped
         | 
| 209 209 | 
             
                    server.send_data '</stream:stream>'
         | 
| 210 | 
            -
                    @stream.stopped?. | 
| 210 | 
            +
                    @stream.stopped?.should == false
         | 
| 211 211 |  | 
| 212 212 | 
             
                  when :stopped
         | 
| 213 213 | 
             
                    EM.stop
         | 
| 214 | 
            -
                    @stream.stopped?. | 
| 215 | 
            -
                    val. | 
| 214 | 
            +
                    @stream.stopped?.should == true
         | 
| 215 | 
            +
                    val.should == '</stream:stream>'
         | 
| 216 216 |  | 
| 217 217 | 
             
                  else
         | 
| 218 218 | 
             
                    EM.stop
         | 
| @@ -225,9 +225,9 @@ describe Blather::Stream::Client do | |
| 225 225 | 
             
              it 'sends client an error on stream:error' do
         | 
| 226 226 | 
             
                @client = mock()
         | 
| 227 227 | 
             
                @client.expects(:receive_data).with do |v|
         | 
| 228 | 
            -
                  v.name. | 
| 229 | 
            -
                  v.text. | 
| 230 | 
            -
                  v.to_s. | 
| 228 | 
            +
                  v.name.should == :conflict
         | 
| 229 | 
            +
                  v.text.should == 'Already signed in'
         | 
| 230 | 
            +
                  v.to_s.should == "Stream Error (conflict): #{v.text}"
         | 
| 231 231 | 
             
                end
         | 
| 232 232 |  | 
| 233 233 | 
             
                state = nil
         | 
| @@ -237,7 +237,7 @@ describe Blather::Stream::Client do | |
| 237 237 | 
             
                    state = :started
         | 
| 238 238 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"
         | 
| 239 239 | 
             
                    server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
         | 
| 240 | 
            -
                    val. | 
| 240 | 
            +
                    val.should match(/stream:stream/)
         | 
| 241 241 |  | 
| 242 242 | 
             
                  when :started
         | 
| 243 243 | 
             
                    state = :stopped
         | 
| @@ -246,7 +246,7 @@ describe Blather::Stream::Client do | |
| 246 246 |  | 
| 247 247 | 
             
                  when :stopped
         | 
| 248 248 | 
             
                    EM.stop
         | 
| 249 | 
            -
                    val. | 
| 249 | 
            +
                    val.should == "</stream:stream>"
         | 
| 250 250 |  | 
| 251 251 | 
             
                  else
         | 
| 252 252 | 
             
                    EM.stop
         | 
| @@ -264,11 +264,11 @@ describe Blather::Stream::Client do | |
| 264 264 | 
             
                    state = :started
         | 
| 265 265 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 266 266 | 
             
                    server.send_data "<stream:features><auth xmlns='http://jabber.org/features/iq-auth'/><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' /></stream:features>"
         | 
| 267 | 
            -
                    val. | 
| 267 | 
            +
                    val.should match(/stream:stream/)
         | 
| 268 268 |  | 
| 269 269 | 
             
                  when :started
         | 
| 270 270 | 
             
                    EM.stop
         | 
| 271 | 
            -
                    val. | 
| 271 | 
            +
                    val.should match(/starttls/)
         | 
| 272 272 |  | 
| 273 273 | 
             
                  else
         | 
| 274 274 | 
             
                    EM.stop
         | 
| @@ -286,13 +286,13 @@ describe Blather::Stream::Client do | |
| 286 286 | 
             
                    state = :started
         | 
| 287 287 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 288 288 | 
             
                    server.send_data "<stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' /></stream:features>"
         | 
| 289 | 
            -
                    val. | 
| 289 | 
            +
                    val.should match(/stream:stream/)
         | 
| 290 290 |  | 
| 291 291 | 
             
                  when :started
         | 
| 292 292 | 
             
                    state = :tls
         | 
| 293 293 | 
             
                    @stream.expects(:start_tls)
         | 
| 294 294 | 
             
                    server.send_data "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"
         | 
| 295 | 
            -
                    val. | 
| 295 | 
            +
                    val.should match(/starttls/)
         | 
| 296 296 |  | 
| 297 297 | 
             
                  when :tls
         | 
| 298 298 | 
             
                    EM.stop
         | 
| @@ -309,23 +309,23 @@ describe Blather::Stream::Client do | |
| 309 309 | 
             
              it 'will fail if TLS negotiation fails' do
         | 
| 310 310 | 
             
                state = nil
         | 
| 311 311 | 
             
                @client = mock()
         | 
| 312 | 
            -
                @client.expects(:receive_data).with { |v| v. | 
| 312 | 
            +
                @client.expects(:receive_data).with { |v| v.should be_kind_of Blather::Stream::TLS::TLSFailure }
         | 
| 313 313 | 
             
                mocked_server(3) do |val, server|
         | 
| 314 314 | 
             
                  case state
         | 
| 315 315 | 
             
                  when nil
         | 
| 316 316 | 
             
                    state = :started
         | 
| 317 317 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' /></stream:features>"
         | 
| 318 | 
            -
                    val. | 
| 318 | 
            +
                    val.should match(/stream:stream/)
         | 
| 319 319 |  | 
| 320 320 | 
             
                  when :started
         | 
| 321 321 | 
             
                    state = :tls
         | 
| 322 322 | 
             
                    @stream.expects(:start_tls).never
         | 
| 323 323 | 
             
                    server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-tls'/></stream:stream>"
         | 
| 324 | 
            -
                    val. | 
| 324 | 
            +
                    val.should match(/starttls/)
         | 
| 325 325 |  | 
| 326 326 | 
             
                  when :tls
         | 
| 327 327 | 
             
                    EM.stop
         | 
| 328 | 
            -
                    val. | 
| 328 | 
            +
                    val.should == "</stream:stream>"
         | 
| 329 329 |  | 
| 330 330 | 
             
                  else
         | 
| 331 331 | 
             
                    EM.stop
         | 
| @@ -339,7 +339,7 @@ describe Blather::Stream::Client do | |
| 339 339 | 
             
                state = nil
         | 
| 340 340 | 
             
                @client = mock()
         | 
| 341 341 | 
             
                @client.expects(:receive_data).with do |v|
         | 
| 342 | 
            -
                  v. | 
| 342 | 
            +
                  v.should be_kind_of Blather::Stream::TLS::TLSFailure
         | 
| 343 343 | 
             
                end
         | 
| 344 344 | 
             
                mocked_server(3) do |val, server|
         | 
| 345 345 | 
             
                  case state
         | 
| @@ -347,17 +347,17 @@ describe Blather::Stream::Client do | |
| 347 347 | 
             
                    state = :started
         | 
| 348 348 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 349 349 | 
             
                    server.send_data "<stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls' /></stream:features>"
         | 
| 350 | 
            -
                    val. | 
| 350 | 
            +
                    val.should match(/stream:stream/)
         | 
| 351 351 |  | 
| 352 352 | 
             
                  when :started
         | 
| 353 353 | 
             
                    state = :tls
         | 
| 354 354 | 
             
                    @stream.expects(:start_tls).never
         | 
| 355 355 | 
             
                    server.send_data "<foo-bar xmlns='urn:ietf:params:xml:ns:xmpp-tls'/></stream:stream>"
         | 
| 356 | 
            -
                    val. | 
| 356 | 
            +
                    val.should match(/starttls/)
         | 
| 357 357 |  | 
| 358 358 | 
             
                  when :tls
         | 
| 359 359 | 
             
                    EM.stop
         | 
| 360 | 
            -
                    val. | 
| 360 | 
            +
                    val.should == "</stream:stream>"
         | 
| 361 361 |  | 
| 362 362 | 
             
                  else
         | 
| 363 363 | 
             
                    EM.stop
         | 
| @@ -376,27 +376,27 @@ describe Blather::Stream::Client do | |
| 376 376 | 
             
                  when nil
         | 
| 377 377 | 
             
                    state = :started
         | 
| 378 378 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism></mechanisms></stream:features>"
         | 
| 379 | 
            -
                    val. | 
| 379 | 
            +
                    val.should match(/stream:stream/)
         | 
| 380 380 |  | 
| 381 381 | 
             
                  when :started
         | 
| 382 382 | 
             
                    state = :auth_sent
         | 
| 383 383 | 
             
                    server.send_data "<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cmVhbG09InNvbWVyZWFsbSIsbm9uY2U9Ik9BNk1HOXRFUUdtMmhoIixxb3A9ImF1dGgiLGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNzCg==</challenge>"
         | 
| 384 | 
            -
                    val. | 
| 384 | 
            +
                    val.should match(/auth.*DIGEST\-MD5/)
         | 
| 385 385 |  | 
| 386 386 | 
             
                  when :auth_sent
         | 
| 387 387 | 
             
                    state = :response1_sent
         | 
| 388 388 | 
             
                    server.send_data "<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cnNwYXV0aD1lYTQwZjYwMzM1YzQyN2I1NTI3Yjg0ZGJhYmNkZmZmZAo=</challenge>"
         | 
| 389 | 
            -
                    val. | 
| 389 | 
            +
                    val.should ==('<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">bm9uY2U9Ik9BNk1HOXRFUUdtMmhoIixjaGFyc2V0PXV0Zi04LHVzZXJuYW1lPSJuIixyZWFsbT0ic29tZXJlYWxtIixjbm9uY2U9Ijc3N2Q0NWJiYmNkZjUwZDQ5YzQyYzcwYWQ3YWNmNWZlIixuYz0wMDAwMDAwMSxxb3A9YXV0aCxkaWdlc3QtdXJpPSJ4bXBwL2QiLHJlc3BvbnNlPTZiNTlhY2Q1ZWJmZjhjZTA0NTYzMGFiMDU2Zjg3MTdm</response>')
         | 
| 390 390 |  | 
| 391 391 | 
             
                  when :response1_sent
         | 
| 392 392 | 
             
                    state = :response2_sent
         | 
| 393 393 | 
             
                    server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
         | 
| 394 | 
            -
                    val. | 
| 394 | 
            +
                    val.should match(%r{<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"\s?/>})
         | 
| 395 395 |  | 
| 396 396 | 
             
                  when :response2_sent
         | 
| 397 397 | 
             
                    EM.stop
         | 
| 398 398 | 
             
                    state = :complete
         | 
| 399 | 
            -
                    val. | 
| 399 | 
            +
                    val.should match(/stream:stream/)
         | 
| 400 400 |  | 
| 401 401 | 
             
                  else
         | 
| 402 402 | 
             
                    EM.stop
         | 
| @@ -413,17 +413,17 @@ describe Blather::Stream::Client do | |
| 413 413 | 
             
                  when nil
         | 
| 414 414 | 
             
                    state = :started
         | 
| 415 415 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism></mechanisms></stream:features>"
         | 
| 416 | 
            -
                    val. | 
| 416 | 
            +
                    val.should match(/stream:stream/)
         | 
| 417 417 |  | 
| 418 418 | 
             
                  when :started
         | 
| 419 419 | 
             
                    state = :auth_sent
         | 
| 420 420 | 
             
                    server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
         | 
| 421 | 
            -
                    val. | 
| 421 | 
            +
                    val.should ==('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">bkBkAG4AcGFzcw==</auth>')
         | 
| 422 422 |  | 
| 423 423 | 
             
                  when :auth_sent
         | 
| 424 424 | 
             
                    EM.stop
         | 
| 425 425 | 
             
                    state = :complete
         | 
| 426 | 
            -
                    val. | 
| 426 | 
            +
                    val.should match(/stream:stream/)
         | 
| 427 427 |  | 
| 428 428 | 
             
                  else
         | 
| 429 429 | 
             
                    EM.stop
         | 
| @@ -441,17 +441,17 @@ describe Blather::Stream::Client do | |
| 441 441 | 
             
                  when nil
         | 
| 442 442 | 
             
                    state = :started
         | 
| 443 443 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>ANONYMOUS</mechanism></mechanisms></stream:features>"
         | 
| 444 | 
            -
                    val. | 
| 444 | 
            +
                    val.should match(/stream:stream/)
         | 
| 445 445 |  | 
| 446 446 | 
             
                  when :started
         | 
| 447 447 | 
             
                    state = :auth_sent
         | 
| 448 448 | 
             
                    server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
         | 
| 449 | 
            -
                    val. | 
| 449 | 
            +
                    val.should ==('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="ANONYMOUS"/>')
         | 
| 450 450 |  | 
| 451 451 | 
             
                  when :auth_sent
         | 
| 452 452 | 
             
                    EM.stop
         | 
| 453 453 | 
             
                    state = :complete
         | 
| 454 | 
            -
                    val. | 
| 454 | 
            +
                    val.should match(/stream:stream/)
         | 
| 455 455 |  | 
| 456 456 | 
             
                  else
         | 
| 457 457 | 
             
                    EM.stop
         | 
| @@ -470,17 +470,17 @@ describe Blather::Stream::Client do | |
| 470 470 | 
             
                  when nil
         | 
| 471 471 | 
             
                    state = :started
         | 
| 472 472 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism></mechanisms></stream:features>"
         | 
| 473 | 
            -
                    val. | 
| 473 | 
            +
                    val.should match(/stream:stream/)
         | 
| 474 474 |  | 
| 475 475 | 
             
                  when :started
         | 
| 476 476 | 
             
                    state = :auth_sent
         | 
| 477 477 | 
             
                    server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
         | 
| 478 | 
            -
                    val. | 
| 478 | 
            +
                    val.should ==('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="ANONYMOUS"/>')
         | 
| 479 479 |  | 
| 480 480 | 
             
                  when :auth_sent
         | 
| 481 481 | 
             
                    EM.stop
         | 
| 482 482 | 
             
                    state = :complete
         | 
| 483 | 
            -
                    val. | 
| 483 | 
            +
                    val.should match(/stream:stream/)
         | 
| 484 484 |  | 
| 485 485 | 
             
                  else
         | 
| 486 486 | 
             
                    EM.stop
         | 
| @@ -494,7 +494,7 @@ describe Blather::Stream::Client do | |
| 494 494 | 
             
                state = nil
         | 
| 495 495 | 
             
                @jid = Blather::JID.new '@d'
         | 
| 496 496 | 
             
                @client = mock()
         | 
| 497 | 
            -
                @client.expects(:receive_data).with { |s| s. | 
| 497 | 
            +
                @client.expects(:receive_data).with { |s| s.should be_instance_of Blather::BlatherError }
         | 
| 498 498 |  | 
| 499 499 | 
             
                mocked_server(2) do |val, server|
         | 
| 500 500 | 
             
                  case state
         | 
| @@ -502,11 +502,11 @@ describe Blather::Stream::Client do | |
| 502 502 | 
             
                    state = :started
         | 
| 503 503 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 504 504 | 
             
                    server.send_data "<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>"
         | 
| 505 | 
            -
                    val. | 
| 505 | 
            +
                    val.should match(/stream:stream/)
         | 
| 506 506 |  | 
| 507 507 | 
             
                  when :started
         | 
| 508 508 | 
             
                    EM.stop
         | 
| 509 | 
            -
                    val. | 
| 509 | 
            +
                    val.should match(/stream:stream/)
         | 
| 510 510 |  | 
| 511 511 | 
             
                  else
         | 
| 512 512 | 
             
                    EM.stop
         | 
| @@ -520,8 +520,8 @@ describe Blather::Stream::Client do | |
| 520 520 | 
             
                state = nil
         | 
| 521 521 | 
             
                @client = mock()
         | 
| 522 522 | 
             
                @client.expects(:receive_data).with do |n|
         | 
| 523 | 
            -
                  n. | 
| 524 | 
            -
                  n.name. | 
| 523 | 
            +
                  n.should be_kind_of(Blather::SASLError)
         | 
| 524 | 
            +
                  n.name.should == :not_authorized
         | 
| 525 525 | 
             
                end
         | 
| 526 526 |  | 
| 527 527 | 
             
                mocked_server(5) do |val, server|
         | 
| @@ -530,27 +530,27 @@ describe Blather::Stream::Client do | |
| 530 530 | 
             
                    state = :started
         | 
| 531 531 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 532 532 | 
             
                    server.send_data "<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism></mechanisms></stream:features>"
         | 
| 533 | 
            -
                    val. | 
| 533 | 
            +
                    val.should match(/stream:stream/)
         | 
| 534 534 |  | 
| 535 535 | 
             
                  when :started
         | 
| 536 536 | 
             
                    state = :failed_md5
         | 
| 537 537 | 
             
                    server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized /></failure>"
         | 
| 538 | 
            -
                    val. | 
| 538 | 
            +
                    val.should match(/mechanism="DIGEST-MD5"/)
         | 
| 539 539 |  | 
| 540 540 | 
             
                  when :failed_md5
         | 
| 541 541 | 
             
                    state = :failed_plain
         | 
| 542 542 | 
             
                    server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized /></failure>"
         | 
| 543 | 
            -
                    val. | 
| 543 | 
            +
                    val.should match(/mechanism="PLAIN"/)
         | 
| 544 544 |  | 
| 545 545 | 
             
                  when :failed_plain
         | 
| 546 546 | 
             
                    state = :failed_anon
         | 
| 547 547 | 
             
                    server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized /></failure>"
         | 
| 548 | 
            -
                    val. | 
| 548 | 
            +
                    val.should match(/mechanism="ANONYMOUS"/)
         | 
| 549 549 |  | 
| 550 550 | 
             
                  when :failed_anon
         | 
| 551 551 | 
             
                    EM.stop
         | 
| 552 552 | 
             
                    state = :complete
         | 
| 553 | 
            -
                    val. | 
| 553 | 
            +
                    val.should match(/\/stream:stream/)
         | 
| 554 554 |  | 
| 555 555 | 
             
                  else
         | 
| 556 556 | 
             
                    EM.stop
         | 
| @@ -567,21 +567,21 @@ describe Blather::Stream::Client do | |
| 567 567 | 
             
                  when nil
         | 
| 568 568 | 
             
                    state = :started
         | 
| 569 569 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism></mechanisms></stream:features>"
         | 
| 570 | 
            -
                    val. | 
| 570 | 
            +
                    val.should match(/stream:stream/)
         | 
| 571 571 |  | 
| 572 572 | 
             
                  when :started
         | 
| 573 573 | 
             
                    state = :failed_md5
         | 
| 574 574 | 
             
                    server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized /></failure>"
         | 
| 575 | 
            -
                    val. | 
| 575 | 
            +
                    val.should match(/mechanism="DIGEST-MD5"/)
         | 
| 576 576 |  | 
| 577 577 | 
             
                  when :failed_md5
         | 
| 578 578 | 
             
                    state = :plain_sent
         | 
| 579 579 | 
             
                    server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
         | 
| 580 | 
            -
                    val. | 
| 580 | 
            +
                    val.should match(/mechanism="PLAIN"/)
         | 
| 581 581 |  | 
| 582 582 | 
             
                  when :plain_sent
         | 
| 583 583 | 
             
                    EM.stop
         | 
| 584 | 
            -
                    val. | 
| 584 | 
            +
                    val.should match(/stream:stream/)
         | 
| 585 585 |  | 
| 586 586 | 
             
                  else
         | 
| 587 587 | 
             
                    EM.stop
         | 
| @@ -599,17 +599,17 @@ describe Blather::Stream::Client do | |
| 599 599 | 
             
                    state = :started
         | 
| 600 600 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 601 601 | 
             
                    server.send_data "<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>CRAM-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>"
         | 
| 602 | 
            -
                    val. | 
| 602 | 
            +
                    val.should match(/stream:stream/)
         | 
| 603 603 |  | 
| 604 604 | 
             
                  when :started
         | 
| 605 605 | 
             
                    state = :auth_sent
         | 
| 606 606 | 
             
                    server.send_data "<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />"
         | 
| 607 | 
            -
                    val. | 
| 607 | 
            +
                    val.should ==('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">bkBkAG4AcGFzcw==</auth>')
         | 
| 608 608 |  | 
| 609 609 | 
             
                  when :auth_sent
         | 
| 610 610 | 
             
                    EM.stop
         | 
| 611 611 | 
             
                    state = :complete
         | 
| 612 | 
            -
                    val. | 
| 612 | 
            +
                    val.should match(/stream:stream/)
         | 
| 613 613 |  | 
| 614 614 | 
             
                  else
         | 
| 615 615 | 
             
                    EM.stop
         | 
| @@ -621,18 +621,18 @@ describe Blather::Stream::Client do | |
| 621 621 | 
             
            =begin
         | 
| 622 622 | 
             
              it 'sends client an error when an unknown mechanism is sent' do
         | 
| 623 623 | 
             
                @client = mock()
         | 
| 624 | 
            -
                @client.expects(:receive_data).with { |v| v. | 
| 624 | 
            +
                @client.expects(:receive_data).with { |v| v.should be_kind_of(Blather::Stream::SASL::UnknownMechanism) }
         | 
| 625 625 | 
             
                started = false
         | 
| 626 626 | 
             
                mocked_server(2) do |val, server|
         | 
| 627 627 | 
             
                  if !started
         | 
| 628 628 | 
             
                    started = true
         | 
| 629 629 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 630 630 | 
             
                    server.send_data "<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>UNKNOWN</mechanism></mechanisms></stream:features>"
         | 
| 631 | 
            -
                    val. | 
| 631 | 
            +
                    val.should match(/stream:stream/)
         | 
| 632 632 |  | 
| 633 633 | 
             
                  else
         | 
| 634 634 | 
             
                    EM.stop
         | 
| 635 | 
            -
                    val. | 
| 635 | 
            +
                    val.should match(/failure(.*)invalid\-mechanism/)
         | 
| 636 636 |  | 
| 637 637 | 
             
                  end
         | 
| 638 638 | 
             
                end
         | 
| @@ -649,7 +649,7 @@ describe Blather::Stream::Client do | |
| 649 649 | 
             
                it "fails on #{error_type}" do
         | 
| 650 650 | 
             
                  @client = mock()
         | 
| 651 651 | 
             
                  @client.expects(:receive_data).with do |n|
         | 
| 652 | 
            -
                    n.name. | 
| 652 | 
            +
                    n.name.should == error_type.gsub('-','_').to_sym
         | 
| 653 653 | 
             
                  end
         | 
| 654 654 | 
             
                  state = nil
         | 
| 655 655 | 
             
                  mocked_server(3) do |val, server|
         | 
| @@ -657,17 +657,17 @@ describe Blather::Stream::Client do | |
| 657 657 | 
             
                    when nil
         | 
| 658 658 | 
             
                      state = :started
         | 
| 659 659 | 
             
                      server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism></mechanisms></stream:features>"
         | 
| 660 | 
            -
                      val. | 
| 660 | 
            +
                      val.should match(/stream:stream/)
         | 
| 661 661 |  | 
| 662 662 | 
             
                    when :started
         | 
| 663 663 | 
             
                      state = :auth_sent
         | 
| 664 664 | 
             
                      server.send_data "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><#{error_type} /></failure>"
         | 
| 665 | 
            -
                      val. | 
| 665 | 
            +
                      val.should ==('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">bkBkAG4AcGFzcw==</auth>')
         | 
| 666 666 |  | 
| 667 667 | 
             
                    when :auth_sent
         | 
| 668 668 | 
             
                      EM.stop
         | 
| 669 669 | 
             
                      state = :complete
         | 
| 670 | 
            -
                      val. | 
| 670 | 
            +
                      val.should match(/\/stream:stream/)
         | 
| 671 671 |  | 
| 672 672 | 
             
                    else
         | 
| 673 673 | 
             
                      EM.stop
         | 
| @@ -681,8 +681,8 @@ describe Blather::Stream::Client do | |
| 681 681 | 
             
              it 'fails when an unknown node comes through during SASL negotiation' do
         | 
| 682 682 | 
             
                @client = mock()
         | 
| 683 683 | 
             
                @client.expects(:receive_data).with do |n|
         | 
| 684 | 
            -
                  n. | 
| 685 | 
            -
                  n.node.element_name. | 
| 684 | 
            +
                  n.should be_instance_of Blather::UnknownResponse
         | 
| 685 | 
            +
                  n.node.element_name.should == 'foo-bar'
         | 
| 686 686 | 
             
                end
         | 
| 687 687 | 
             
                state = nil
         | 
| 688 688 | 
             
                mocked_server(3) do |val, server|
         | 
| @@ -690,17 +690,17 @@ describe Blather::Stream::Client do | |
| 690 690 | 
             
                  when nil
         | 
| 691 691 | 
             
                    state = :started
         | 
| 692 692 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism></mechanisms></stream:features>"
         | 
| 693 | 
            -
                    val. | 
| 693 | 
            +
                    val.should match(/stream:stream/)
         | 
| 694 694 |  | 
| 695 695 | 
             
                  when :started
         | 
| 696 696 | 
             
                    state = :auth_sent
         | 
| 697 697 | 
             
                    server.send_data "<foo-bar />"
         | 
| 698 | 
            -
                    val. | 
| 698 | 
            +
                    val.should ==('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">bkBkAG4AcGFzcw==</auth>')
         | 
| 699 699 |  | 
| 700 700 | 
             
                  when :auth_sent
         | 
| 701 701 | 
             
                    EM.stop
         | 
| 702 702 | 
             
                    state = :complete
         | 
| 703 | 
            -
                    val. | 
| 703 | 
            +
                    val.should match(/\/stream:stream/)
         | 
| 704 704 |  | 
| 705 705 | 
             
                  else
         | 
| 706 706 | 
             
                    EM.stop
         | 
| @@ -722,18 +722,18 @@ describe Blather::Stream::Client do | |
| 722 722 | 
             
                    state = :started
         | 
| 723 723 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 724 724 | 
             
                    server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
         | 
| 725 | 
            -
                    val. | 
| 725 | 
            +
                    val.should match(/stream:stream/)
         | 
| 726 726 |  | 
| 727 727 | 
             
                  when :started
         | 
| 728 728 | 
             
                    state = :complete
         | 
| 729 729 | 
             
                    val =~ %r{<iq[^>]+id="([^"]+)"}
         | 
| 730 730 | 
             
                    server.send_data "<iq type='result' id='#{$1}'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>#{@jid}/server_resource</jid></bind></iq>"
         | 
| 731 731 | 
             
                    server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
         | 
| 732 | 
            -
                    val. | 
| 732 | 
            +
                    val.should match(%r{<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"\s?/>})
         | 
| 733 733 |  | 
| 734 734 | 
             
                  when :complete
         | 
| 735 735 | 
             
                    EM.stop
         | 
| 736 | 
            -
                    @stream.jid. | 
| 736 | 
            +
                    @stream.jid.should == Blather::JID.new('n@d/server_resource')
         | 
| 737 737 |  | 
| 738 738 | 
             
                  else
         | 
| 739 739 | 
             
                    EM.stop
         | 
| @@ -754,19 +754,19 @@ describe Blather::Stream::Client do | |
| 754 754 | 
             
                  when nil
         | 
| 755 755 | 
             
                    state = :started
         | 
| 756 756 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
         | 
| 757 | 
            -
                    val. | 
| 757 | 
            +
                    val.should match(/stream:stream/)
         | 
| 758 758 |  | 
| 759 759 | 
             
                  when :started
         | 
| 760 760 | 
             
                    state = :complete
         | 
| 761 761 | 
             
                    doc = parse_stanza val
         | 
| 762 | 
            -
                    doc.xpath('/iq/bind_ns:bind/bind_ns:resource[.="r"]', :bind_ns => Blather::Stream::Resource::BIND_NS). | 
| 762 | 
            +
                    doc.xpath('/iq/bind_ns:bind/bind_ns:resource[.="r"]', :bind_ns => Blather::Stream::Resource::BIND_NS).should_not be_empty
         | 
| 763 763 |  | 
| 764 764 | 
             
                    server.send_data "<iq type='result' id='#{doc.find_first('iq')['id']}'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>#{@jid}</jid></bind></iq>"
         | 
| 765 765 | 
             
                    server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
         | 
| 766 766 |  | 
| 767 767 | 
             
                  when :complete
         | 
| 768 768 | 
             
                    EM.stop
         | 
| 769 | 
            -
                    @stream.jid. | 
| 769 | 
            +
                    @stream.jid.should == Blather::JID.new('n@d/r')
         | 
| 770 770 |  | 
| 771 771 | 
             
                  else
         | 
| 772 772 | 
             
                    EM.stop
         | 
| @@ -787,14 +787,14 @@ describe Blather::Stream::Client do | |
| 787 787 | 
             
                    state = :started
         | 
| 788 788 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 789 789 | 
             
                    server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
         | 
| 790 | 
            -
                    val. | 
| 790 | 
            +
                    val.should match(/stream:stream/)
         | 
| 791 791 |  | 
| 792 792 | 
             
                  when :started
         | 
| 793 793 | 
             
                    state = :complete
         | 
| 794 794 | 
             
                    val =~ %r{<iq[^>]+id="([^"]+)"}
         | 
| 795 795 | 
             
                    @client.expects(:receive_data).with("BIND result ID mismatch. Expected: #{$1}. Received: #{$1}-bad")
         | 
| 796 796 | 
             
                    server.send_data "<iq type='result' id='#{$1}-bad'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>#{@jid}/server_resource</jid></bind></iq>"
         | 
| 797 | 
            -
                    val. | 
| 797 | 
            +
                    val.should match(%r{<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"\s?/>})
         | 
| 798 798 |  | 
| 799 799 | 
             
                  when :complete
         | 
| 800 800 | 
             
                    EM.stop
         | 
| @@ -812,24 +812,24 @@ describe Blather::Stream::Client do | |
| 812 812 | 
             
                state = nil
         | 
| 813 813 | 
             
                @client = mock()
         | 
| 814 814 | 
             
                @client.expects(:receive_data).with do |n|
         | 
| 815 | 
            -
                  n.name. | 
| 815 | 
            +
                  n.name.should == :bad_request
         | 
| 816 816 | 
             
                end
         | 
| 817 817 | 
             
                mocked_server(3) do |val, server|
         | 
| 818 818 | 
             
                  case state
         | 
| 819 819 | 
             
                  when nil
         | 
| 820 820 | 
             
                    state = :started
         | 
| 821 821 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'><stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
         | 
| 822 | 
            -
                    val. | 
| 822 | 
            +
                    val.should match(/stream:stream/)
         | 
| 823 823 |  | 
| 824 824 | 
             
                  when :started
         | 
| 825 825 | 
             
                    state = :complete
         | 
| 826 826 | 
             
                    doc = parse_stanza val
         | 
| 827 | 
            -
                    doc.xpath('/iq/bind_ns:bind/bind_ns:resource[.="r"]', :bind_ns => Blather::Stream::Resource::BIND_NS). | 
| 827 | 
            +
                    doc.xpath('/iq/bind_ns:bind/bind_ns:resource[.="r"]', :bind_ns => Blather::Stream::Resource::BIND_NS).should_not be_empty
         | 
| 828 828 | 
             
                    server.send_data "<iq type='error' id='#{doc.find_first('iq')['id']}'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>r</resource></bind><error type='modify'><bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>"
         | 
| 829 829 |  | 
| 830 830 | 
             
                  when :complete
         | 
| 831 831 | 
             
                    EM.stop
         | 
| 832 | 
            -
                    val. | 
| 832 | 
            +
                    val.should match(/\/stream:stream/)
         | 
| 833 833 |  | 
| 834 834 | 
             
                  else
         | 
| 835 835 | 
             
                    EM.stop
         | 
| @@ -843,8 +843,8 @@ describe Blather::Stream::Client do | |
| 843 843 | 
             
                state = nil
         | 
| 844 844 | 
             
                @client = mock()
         | 
| 845 845 | 
             
                @client.expects(:receive_data).with do |n|
         | 
| 846 | 
            -
                  n. | 
| 847 | 
            -
                  n.node.element_name. | 
| 846 | 
            +
                  n.should be_instance_of Blather::UnknownResponse
         | 
| 847 | 
            +
                  n.node.element_name.should == 'foo-bar'
         | 
| 848 848 | 
             
                end
         | 
| 849 849 | 
             
                mocked_server(3) do |val, server|
         | 
| 850 850 | 
             
                  case state
         | 
| @@ -852,17 +852,17 @@ describe Blather::Stream::Client do | |
| 852 852 | 
             
                    state = :started
         | 
| 853 853 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 854 854 | 
             
                    server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
         | 
| 855 | 
            -
                    val. | 
| 855 | 
            +
                    val.should match(/stream:stream/)
         | 
| 856 856 |  | 
| 857 857 | 
             
                  when :started
         | 
| 858 858 | 
             
                    state = :complete
         | 
| 859 859 | 
             
                    doc = parse_stanza val
         | 
| 860 | 
            -
                    doc.xpath('/iq/bind_ns:bind/bind_ns:resource[.="r"]', :bind_ns => Blather::Stream::Resource::BIND_NS). | 
| 860 | 
            +
                    doc.xpath('/iq/bind_ns:bind/bind_ns:resource[.="r"]', :bind_ns => Blather::Stream::Resource::BIND_NS).should_not be_empty
         | 
| 861 861 | 
             
                    server.send_data "<foo-bar />"
         | 
| 862 862 |  | 
| 863 863 | 
             
                  when :complete
         | 
| 864 864 | 
             
                    EM.stop
         | 
| 865 | 
            -
                    val. | 
| 865 | 
            +
                    val.should match(/\/stream:stream/)
         | 
| 866 866 |  | 
| 867 867 | 
             
                  else
         | 
| 868 868 | 
             
                    EM.stop
         | 
| @@ -883,12 +883,12 @@ describe Blather::Stream::Client do | |
| 883 883 | 
             
                    state = :started
         | 
| 884 884 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 885 885 | 
             
                    server.send_data "<stream:features><session xmlns='urn:ietf:params:xml:ns:xmpp-session' /></stream:features>"
         | 
| 886 | 
            -
                    val. | 
| 886 | 
            +
                    val.should match(/stream:stream/)
         | 
| 887 887 |  | 
| 888 888 | 
             
                  when :started
         | 
| 889 889 | 
             
                    state = :completed
         | 
| 890 890 | 
             
                    doc = parse_stanza val
         | 
| 891 | 
            -
                    doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS). | 
| 891 | 
            +
                    doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS).should_not be_empty
         | 
| 892 892 | 
             
                    server.send_data "<iq from='d' type='result' id='#{doc.find_first('iq')['id']}' />"
         | 
| 893 893 | 
             
                    server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
         | 
| 894 894 |  | 
| @@ -908,7 +908,7 @@ describe Blather::Stream::Client do | |
| 908 908 | 
             
                state = nil
         | 
| 909 909 | 
             
                @client = mock()
         | 
| 910 910 | 
             
                @client.expects(:receive_data).with do |n|
         | 
| 911 | 
            -
                  n.name. | 
| 911 | 
            +
                  n.name.should == :internal_server_error
         | 
| 912 912 | 
             
                end
         | 
| 913 913 | 
             
                mocked_server(3) do |val, server|
         | 
| 914 914 | 
             
                  case state
         | 
| @@ -916,17 +916,17 @@ describe Blather::Stream::Client do | |
| 916 916 | 
             
                    state = :started
         | 
| 917 917 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 918 918 | 
             
                    server.send_data "<stream:features><session xmlns='urn:ietf:params:xml:ns:xmpp-session' /></stream:features>"
         | 
| 919 | 
            -
                    val. | 
| 919 | 
            +
                    val.should match(/stream:stream/)
         | 
| 920 920 |  | 
| 921 921 | 
             
                  when :started
         | 
| 922 922 | 
             
                    state = :completed
         | 
| 923 923 | 
             
                    doc = parse_stanza val
         | 
| 924 | 
            -
                    doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS). | 
| 924 | 
            +
                    doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS).should_not be_empty
         | 
| 925 925 | 
             
                    server.send_data "<iq from='d' type='error' id='#{doc.find_first('iq')['id']}'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/><error type='wait'><internal-server-error xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>"
         | 
| 926 926 |  | 
| 927 927 | 
             
                  when :completed
         | 
| 928 928 | 
             
                    EM.stop
         | 
| 929 | 
            -
                    val. | 
| 929 | 
            +
                    val.should match(/\/stream:stream/)
         | 
| 930 930 |  | 
| 931 931 | 
             
                  else
         | 
| 932 932 | 
             
                    EM.stop
         | 
| @@ -940,8 +940,8 @@ describe Blather::Stream::Client do | |
| 940 940 | 
             
                state = nil
         | 
| 941 941 | 
             
                @client = mock()
         | 
| 942 942 | 
             
                @client.expects(:receive_data).with do |n|
         | 
| 943 | 
            -
                  n. | 
| 944 | 
            -
                  n.node.element_name. | 
| 943 | 
            +
                  n.should be_instance_of Blather::UnknownResponse
         | 
| 944 | 
            +
                  n.node.element_name.should == 'foo-bar'
         | 
| 945 945 | 
             
                end
         | 
| 946 946 | 
             
                mocked_server(3) do |val, server|
         | 
| 947 947 | 
             
                  case state
         | 
| @@ -949,17 +949,17 @@ describe Blather::Stream::Client do | |
| 949 949 | 
             
                    state = :started
         | 
| 950 950 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
         | 
| 951 951 | 
             
                    server.send_data "<stream:features><session xmlns='urn:ietf:params:xml:ns:xmpp-session' /></stream:features>"
         | 
| 952 | 
            -
                    val. | 
| 952 | 
            +
                    val.should match(/stream:stream/)
         | 
| 953 953 |  | 
| 954 954 | 
             
                  when :started
         | 
| 955 955 | 
             
                    state = :completed
         | 
| 956 956 | 
             
                    doc = parse_stanza val
         | 
| 957 | 
            -
                    doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS). | 
| 957 | 
            +
                    doc.find('/iq[@type="set" and @to="d"]/sess_ns:session', :sess_ns => Blather::Stream::Session::SESSION_NS).should_not be_empty
         | 
| 958 958 | 
             
                    server.send_data '<foo-bar />'
         | 
| 959 959 |  | 
| 960 960 | 
             
                  when :completed
         | 
| 961 961 | 
             
                    EM.stop
         | 
| 962 | 
            -
                    val. | 
| 962 | 
            +
                    val.should match(/\/stream:stream/)
         | 
| 963 963 |  | 
| 964 964 | 
             
                  else
         | 
| 965 965 | 
             
                    EM.stop
         | 
| @@ -972,8 +972,8 @@ describe Blather::Stream::Client do | |
| 972 972 | 
             
              it 'sends client an error and reply to the server on parse error' do
         | 
| 973 973 | 
             
                @client = mock()
         | 
| 974 974 | 
             
                @client.expects(:receive_data).with do |v|
         | 
| 975 | 
            -
                  v. | 
| 976 | 
            -
                  v.message. | 
| 975 | 
            +
                  v.should be_kind_of Blather::ParseError
         | 
| 976 | 
            +
                  v.message.should match(/generate\-parse\-error/)
         | 
| 977 977 | 
             
                end
         | 
| 978 978 | 
             
                state = nil
         | 
| 979 979 | 
             
                mocked_server(3) do |val, server|
         | 
| @@ -982,7 +982,7 @@ describe Blather::Stream::Client do | |
| 982 982 | 
             
                    state = :started
         | 
| 983 983 | 
             
                    server.send_data "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"
         | 
| 984 984 | 
             
                    server.send_data "<stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind' /></stream:features>"
         | 
| 985 | 
            -
                    val. | 
| 985 | 
            +
                    val.should match(/stream:stream/)
         | 
| 986 986 |  | 
| 987 987 | 
             
                  when :started
         | 
| 988 988 | 
             
                    state = :parse_error
         | 
| @@ -990,7 +990,7 @@ describe Blather::Stream::Client do | |
| 990 990 |  | 
| 991 991 | 
             
                  when :parse_error
         | 
| 992 992 | 
             
                    EM.stop
         | 
| 993 | 
            -
                    val. | 
| 993 | 
            +
                    val.should == "<stream:error><xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error></stream:stream>"
         | 
| 994 994 |  | 
| 995 995 | 
             
                  else
         | 
| 996 996 | 
             
                    EM.stop
         | 
| @@ -1007,7 +1007,7 @@ describe Blather::Stream::Client do | |
| 1007 1007 | 
             
                msg = Blather::Stanza::Message.new 'to@jid.com', 'body'
         | 
| 1008 1008 | 
             
                msg.from = 'node@jid.com'
         | 
| 1009 1009 | 
             
                comp = Blather::Stream::Client.new nil, client, 'node@jid.com/resource', 'pass'
         | 
| 1010 | 
            -
                comp.expects(:send_data).with { |s| s. | 
| 1010 | 
            +
                comp.expects(:send_data).with { |s| s.should match(/^<message[^>]*from="node@jid\.com\/resource"/) }
         | 
| 1011 1011 | 
             
                comp.send msg
         | 
| 1012 1012 | 
             
              end
         | 
| 1013 1013 |  | 
| @@ -1017,7 +1017,7 @@ describe Blather::Stream::Client do | |
| 1017 1017 | 
             
                client.stubs(:jid=)
         | 
| 1018 1018 | 
             
                msg = Blather::Stanza::Message.new 'to@jid.com', 'body'
         | 
| 1019 1019 | 
             
                comp = Blather::Stream::Client.new nil, client, 'node@jid.com/resource', 'pass'
         | 
| 1020 | 
            -
                comp.expects(:send_data).with { |s| s. | 
| 1020 | 
            +
                comp.expects(:send_data).with { |s| s.should_not match(/^<message[^>]*from=/); true }
         | 
| 1021 1021 | 
             
                comp.send msg
         | 
| 1022 1022 | 
             
              end
         | 
| 1023 1023 |  | 
| @@ -1030,7 +1030,7 @@ describe Blather::Stream::Client do | |
| 1030 1030 | 
             
                msg.xhtml = '<i>xhtml</i> body'
         | 
| 1031 1031 |  | 
| 1032 1032 | 
             
                comp = Blather::Stream::Client.new nil, client, 'node@jid.com/resource', 'pass'
         | 
| 1033 | 
            -
                comp.expects(:send_data).with { |s| s. | 
| 1033 | 
            +
                comp.expects(:send_data).with { |s| s.should_not match(/\n/); true }
         | 
| 1034 1034 | 
             
                comp.send msg
         | 
| 1035 1035 | 
             
              end
         | 
| 1036 1036 | 
             
            end
         |