spec/muc_util_spec.lua
changeset 10719 ad86b93093a3
parent 9216 172f93f752b8
equal deleted inserted replaced
10718:9ecad2304297 10719:ad86b93093a3
     1 local muc_util;
     1 local muc_util;
     2 
     2 
     3 local st = require "util.stanza";
     3 local st = require "util.stanza";
     4 
     4 
     5 do
     5 do
     6 	local old_pp = package.path;
     6 	-- XXX Hack for lack of a mock moduleapi
     7 	package.path = "./?.lib.lua;"..package.path;
     7 	local env = setmetatable({
     8 	muc_util = require "plugins.muc.util";
     8 		module = {
     9 	package.path = old_pp;
     9 			_shared = {};
    10 end
    10 			-- Close enough to the real module:shared() for our purposes here
       
    11 			shared = function (self, name)
       
    12 				local t = self._shared[name];
       
    13 				if t == nil then
       
    14 					t = {};
       
    15 					self._shared[name] = t;
       
    16 				end
       
    17 				return t;
       
    18 			end;
       
    19 		}
       
    20 	}, { __index = _ENV or _G });
       
    21 	muc_util = require "util.envload".envloadfile("plugins/muc/util.lib.lua", env)();
       
    22 	end
    11 
    23 
    12 describe("muc/util", function ()
    24 describe("muc/util", function ()
    13 	describe("filter_muc_x()", function ()
    25 	describe("filter_muc_x()", function ()
    14 		it("correctly filters muc#user", function ()
    26 		it("correctly filters muc#user", function ()
    15 			local stanza = st.message({ to = "to", from = "from", id = "foo" })
    27 			local stanza = st.message({ to = "to", from = "from", id = "foo" })