# encoding: UTF-8 require 'vines' require 'minitest/autorun' class ErrorTest < MiniTest::Unit::TestCase def test_sasl_error_without_text expected = %q{} assert_equal expected, Vines::SaslErrors::TemporaryAuthFailure.new.to_xml end def test_sasl_error_with_text text = %q{busted} expected = %q{%s} % text assert_equal expected, Vines::SaslErrors::TemporaryAuthFailure.new('busted').to_xml end def test_stream_error_without_text expected = %q{} assert_equal expected, Vines::StreamErrors::InternalServerError.new.to_xml end def test_stream_error_with_text text = %q{busted} expected = %q{%s} % text assert_equal expected, Vines::StreamErrors::InternalServerError.new('busted').to_xml end def test_stanza_error_with_bad_type node = node('') assert_raises(RuntimeError) { Vines::StanzaErrors::BadRequest.new(node, 'bogus') } end def test_stanza_error_with_bad_stanza node = node('') assert_raises(RuntimeError) { Vines::StanzaErrors::BadRequest.new(node, 'modify') } end def test_stanza_error_without_text error = %q{} expected = %q{%s} % error node = node(%Q{}) assert_equal expected, Vines::StanzaErrors::BadRequest.new(node, 'modify').to_xml end def test_stanza_error_with_text text = %q{busted} error = %q{%s} % text expected = %q{%s} % error node = node(%Q{}) assert_equal expected, Vines::StanzaErrors::BadRequest.new(node, 'modify', 'busted').to_xml end private def node(xml) Nokogiri::XML(xml).root end end