forked from lunarmodules/busted
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue lunarmodules#320 Access spec declaration methods
This allows helper modules to declare tests like the following: -- test_helper.lua local it = require 'busted'.it local function make_test(a, b) it('should check ' .. a .. ' same as ' .. b, function() assert.same(a, b) end) end return { make_test = make_test } And then use the helper modules like this: -- test_spec.lua local make_test = require 'test_helpers'.make_test describe('things', function() make_test(1, 2) make_test(4, 4) end) This is now possible by exposing the busted executor functions via `require 'busted'` so they can be imported by helper modules.
- Loading branch information
Showing
4 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- This is a dummy file so it can be used in busted's specs | ||
-- without adding ./?/init.lua to the lua path | ||
return require 'busted.init' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
describe('tests require "busted"', function() | ||
local describe = describe | ||
local context = context | ||
local it = it | ||
local pending = pending | ||
local spec = spec | ||
local test = test | ||
local setup = setup | ||
local teardown = teardown | ||
local before_each = before_each | ||
local after_each = after_each | ||
|
||
it('does not import init', function() | ||
assert.is_nil(require 'busted'.init) | ||
end) | ||
|
||
it('imports file executor', function() | ||
assert.is_function(require 'busted'.file) | ||
end) | ||
|
||
it('imports describe/it/pending', function() | ||
assert.is_equal(describe, require 'busted'.describe) | ||
assert.is_equal(it, require 'busted'.it) | ||
assert.is_equal(pending, require 'busted'.pending) | ||
end) | ||
|
||
it('imports aliases', function() | ||
assert.is_equal(context, require 'busted'.context) | ||
assert.is_equal(spec, require 'busted'.spec) | ||
assert.is_equal(test, require 'busted'.test) | ||
end) | ||
|
||
it('imports support functions', function() | ||
assert.is_equal(setup, require 'busted'.setup) | ||
assert.is_equal(teardown, require 'busted'.teardown) | ||
assert.is_equal(before_each, require 'busted'.before_each) | ||
assert.is_equal(after_each, require 'busted'.after_each) | ||
end) | ||
end) |