-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathColdBoxBaseSpec.cfc
52 lines (46 loc) · 1.91 KB
/
ColdBoxBaseSpec.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Easily do integration tests by using ColdBox's internal request system.
*/
component extends='Integrated.BaseSpecs.AbstractBaseSpec' {
function beforeAll(
requestEngine = new Integrated.Engines.Request.ColdBoxRequestEngine(),
overrideMetadata = {}
) {
passOnMetadata( arguments.requestEngine, arguments.overrideMetadata );
requestEngine.beforeAll();
super.beforeAll(
requestEngine = arguments.requestEngine,
domEngine = new Integrated.Engines.Assertion.JSoupAssertionEngine(),
frameworkEngine = new Integrated.Engines.Assertion.ColdBoxAssertionEngine(),
interactionEngine = new Integrated.Engines.Interaction.JSoupInteractionEngine()
);
}
function afterAll() {
super.afterAll();
// IMPORTANT: otherwise, ColdBox keeps the last request cached or something
requestEngine.afterAll();
}
private function passOnMetadata(baseTestCase, overrideMetadata = {}) {
var md = structIsEmpty(arguments.overrideMetadata) ? getMetadata(this) : arguments.overrideMetadata;
// Inspect for appMapping annotation
if (structKeyExists(md, "appMapping")) {
arguments.baseTestCase.setAppMapping(md.appMapping);
}
// Configuration File mapping
if (structKeyExists(md, "configMapping")) {
arguments.baseTestCase.setConfigMapping(md.configMapping);
}
// ColdBox App Key
if (structKeyExists(md, "coldboxAppKey")) {
arguments.baseTestCase.setColdboxAppKey(md.coldboxAppKey);
}
// Load coldBox annotation
if (structKeyExists(md, "loadColdbox")) {
arguments.baseTestCase.loadColdbox = md.loadColdbox;
}
// unLoad coldBox annotation
if (structKeyExists(md, "unLoadColdbox")) {
arguments.baseTestCase.unLoadColdbox = md.unLoadColdbox;
}
}
}