summaryrefslogtreecommitdiffstats
path: root/test/assertions.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-28 14:47:34 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-28 14:47:34 +0100
commit4aa66338fce505566a2fe6ba6aee79ddf3f656a2 (patch)
treeffce4b558735f6a41228542f8c36e3a6ba1e562d /test/assertions.js
parent8cda844ef12cf87525024348c104413def02ed7f (diff)
downloadgitbook-4aa66338fce505566a2fe6ba6aee79ddf3f656a2.zip
gitbook-4aa66338fce505566a2fe6ba6aee79ddf3f656a2.tar.gz
gitbook-4aa66338fce505566a2fe6ba6aee79ddf3f656a2.tar.bz2
Add init command
Diffstat (limited to 'test/assertions.js')
-rw-r--r--test/assertions.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/test/assertions.js b/test/assertions.js
index 56da249..f96fdc1 100644
--- a/test/assertions.js
+++ b/test/assertions.js
@@ -1,18 +1,31 @@
var fs = require('fs');
+var path = require('path');
var _ = require('lodash');
var cheerio = require('cheerio');
var should = require('should');
// Assertions to test if an Output has generated a file
should.Assertion.add('file', function(file, description) {
+ var rootFolder;
+ if (_.isFunction(this.obj.root)) {
+ rootFolder = this.obj.root();
+ } else {
+ rootFolder = this.obj;
+ }
+
this.params = {
- actual: this.obj.root(),
+ actual: rootFolder,
operator: 'have file ' + file,
message: description
};
- this.obj.should.have.property('resolve').which.is.a.Function;
- this.assert(fs.existsSync(this.obj.resolve(file)));
+ if (_.isFunction(this.obj.resolve)) {
+ file = this.obj.resolve(file);
+ } else {
+ file = path.resolve(rootFolder, file);
+ }
+
+ this.assert(fs.existsSync(file));
});
should.Assertion.add('html', function(rules, description) {