From 64b6c3fbaf3eb7c530e7532b39954415b25dc532 Mon Sep 17 00:00:00 2001 From: eskerda Date: Thu, 11 Feb 2021 09:16:47 +0100 Subject: [PATCH] feat(helpers): Allow helpers to extend busted --- busted/modules/helper_loader.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/busted/modules/helper_loader.lua b/busted/modules/helper_loader.lua index 300eb166..e7a45f31 100644 --- a/busted/modules/helper_loader.lua +++ b/busted/modules/helper_loader.lua @@ -6,14 +6,21 @@ return function() local loadHelper = function(busted, helper, options) local old_arg = _G.arg local success, err = pcall(function() + local fn + utils.copy_interpreter_args(options.arguments) _G.arg = options.arguments + if helper:match('%.lua$') then - dofile(path.normpath(helper)) + fn = dofile(path.normpath(helper)) elseif hasMoon and helper:match('%.moon$') then - moonscript.dofile(path.normpath(helper)) + fn = moonscript.dofile(path.normpath(helper)) else - require(helper) + fn = require(helper) + end + + if type(fn) == 'function' then + assert(fn(busted, helper, options)) end end)