diff options
Diffstat (limited to 'test/assertions.js')
-rw-r--r-- | test/assertions.js | 19 |
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) { |