Diff

spec/muc_util_spec.lua @ 11120:b2331f3dfeea

Merge 0.11->trunk
author Matthew Wild <mwild1@gmail.com>
date Wed, 30 Sep 2020 09:50:33 +0100
parent 10715:ad86b93093a3
line wrap: on
line diff
--- a/spec/muc_util_spec.lua	Thu Oct 01 15:08:58 2020 +0100
+++ b/spec/muc_util_spec.lua	Wed Sep 30 09:50:33 2020 +0100
@@ -3,11 +3,23 @@
 local st = require "util.stanza";
 
 do
-	local old_pp = package.path;
-	package.path = "./?.lib.lua;"..package.path;
-	muc_util = require "plugins.muc.util";
-	package.path = old_pp;
-end
+	-- XXX Hack for lack of a mock moduleapi
+	local env = setmetatable({
+		module = {
+			_shared = {};
+			-- Close enough to the real module:shared() for our purposes here
+			shared = function (self, name)
+				local t = self._shared[name];
+				if t == nil then
+					t = {};
+					self._shared[name] = t;
+				end
+				return t;
+			end;
+		}
+	}, { __index = _ENV or _G });
+	muc_util = require "util.envload".envloadfile("plugins/muc/util.lib.lua", env)();
+	end
 
 describe("muc/util", function ()
 	describe("filter_muc_x()", function ()