test/stanza/iq/session_test.rb in vines-0.4.5 vs test/stanza/iq/session_test.rb in vines-0.4.6

- old
+ new

@@ -1,26 +1,25 @@ # encoding: UTF-8 -require 'vines' -require 'ext/nokogiri' -require 'minitest/autorun' +require 'test_helper' -class SessionTest < MiniTest::Unit::TestCase - def test_session - stream = MiniTest::Mock.new - stream.expect(:domain, 'wonderland.lit') - stream.expect(:user, Vines::User.new(jid: 'alice@wonderland.lit/tea')) - expected = node(%q{<iq from="wonderland.lit" id="42" to="alice@wonderland.lit/tea" type="result"/>}) - stream.expect(:write, nil, [expected]) +describe Vines::Stanza::Iq::Session do + subject { Vines::Stanza::Iq::Session.new(xml, stream) } + let(:stream) { MiniTest::Mock.new } + let(:alice) { Vines::User.new(jid: 'alice@wonderland.lit/tea') } - node = node(%q{<iq id="42" type="set"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq>}) - stanza = Vines::Stanza::Iq::Session.new(node, stream) - stanza.process - assert stream.verify - end + describe 'when session initiation is requested' do + let(:xml) { node(%q{<iq id="42" type="set"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq>}) } + let(:result) { node(%q{<iq from="wonderland.lit" id="42" to="alice@wonderland.lit/tea" type="result"/>}) } - private + before do + stream.expect :domain, 'wonderland.lit' + stream.expect :user, alice + stream.expect :write, nil, [result] + end - def node(xml) - Nokogiri::XML(xml).root + it 'just returns a result to satisy older clients' do + subject.process + stream.verify + end end end