This repository has been archived by the owner on Oct 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 141
/
Copy pathrunner.js
44 lines (40 loc) · 1.46 KB
/
runner.js
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
var fs = require('fs'),
expect = require('chai').expect,
yaml = require('js-yaml'),
runner = require('../lib/runner');
module.exports.run = runner.run;
// loops through the language specific examples within the examples.yml file and calls the cb function with each individual example
function iterateCodeExamples(language, cb) {
var examples = yaml.safeLoad(fs.readFileSync('./examples/' + language + '.yml', 'utf8'));
if (examples) {
for (var framework in examples) {
for (var example in examples[framework]) {
cb(framework, example, examples[framework][example]);
}
}
}
}
module.exports.assertCodeExamples = function(language, version) {
describe('example challenges', function() {
iterateCodeExamples(language, function(framework, name, example) {
it('should define an initial code block', function() {
expect(example.initial).to.be.a('string');
});
it('should have a passing ' + name + ' example', function(done) {
runner.run({
language: language,
languageVersion: version,
setup: example.setup,
code: example.answer,
fixture: example.fixture,
testFramework: framework
}, function(buffer) {
expect(buffer.stdout).to.not.contain('<FAILED::>');
expect(buffer.stdout).to.not.contain('<ERROR::>');
if (buffer.stderr) console.log(buffer.stderr);
done();
});
});
});
});
};