Sha256: f921074a67d34e41d3d915c8d0d81c6e5b71b7540bd52b2a7e1b9c1f4f7ef4d6
Contents?: true
Size: 1.56 KB
Versions: 19
Compression:
Stored size: 1.56 KB
Contents
# encoding: UTF-8 require 'test_helper' describe Vines::Stream::Component::Handshake do subject { Vines::Stream::Component::Handshake.new(stream) } let(:stream) { MiniTest::Mock.new } describe 'when invalid element is received' do it 'raises a not-authorized stream error' do node = node('<message/>') -> { subject.node(node) }.must_raise Vines::StreamErrors::NotAuthorized end end describe 'when handshake with no text is received' do it 'raises a not-authorized stream error' do stream.expect :secret, 'secr3t' node = node('<handshake/>') -> { subject.node(node) }.must_raise Vines::StreamErrors::NotAuthorized stream.verify end end describe 'when handshake with invalid secret is received' do it 'raises a not-authorized stream error' do stream.expect :secret, 'secr3t' node = node('<handshake>bogus</handshake>') -> { subject.node(node) }.must_raise Vines::StreamErrors::NotAuthorized stream.verify end end describe 'when good handshake is received' do let(:router) { MiniTest::Mock.new } before do router.expect :<<, nil, [stream] stream.expect :router, router stream.expect :secret, 'secr3t' stream.expect :write, nil, ['<handshake/>'] stream.expect :advance, nil, [Vines::Stream::Component::Ready.new(stream)] end it 'completes the handshake and advances the stream into the ready state' do node = node('<handshake>secr3t</handshake>') subject.node(node) stream.verify router.verify end end end
Version data entries
19 entries across 19 versions & 3 rubygems