# encoding: UTF-8 require 'tmpdir' require 'vines' require 'ext/nokogiri' require 'minitest/autorun' class DiscoItemsTest < MiniTest::Unit::TestCase def setup @stream = MiniTest::Mock.new end def test_component_items query = %q{} node = node(%Q{#{query}}) expected = node(%q{ }.strip.gsub(/\n|\s{2,}/, '')) config = Vines::Config.new do host 'wonderland.lit' do storage(:fs) { dir Dir.tmpdir } components 'tea' => 'secr3t', 'cake' => 'passw0rd' end end @stream.expect(:user, Vines::User.new(:jid => 'alice@wonderland.lit/home')) @stream.expect(:write, nil, [expected]) @stream.expect(:config, config) stanza = Vines::Stanza::Iq::DiscoItems.new(node, @stream) stanza.process assert @stream.verify end private def node(xml) Nokogiri::XML(xml).root end end