summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-03-23 23:32:07 +0100
committerSamy Pessé <samypesse@gmail.com>2015-03-23 23:32:07 +0100
commit868a3186dd40e57ec1c38174be1db28dfd4c85c4 (patch)
tree6900fdf85bbd0f11caa9814c661ce2f03f26b4f6
parent17b546181c0af8f3086fdf1b38b39a2bee7155e4 (diff)
downloadgitbook-868a3186dd40e57ec1c38174be1db28dfd4c85c4.zip
gitbook-868a3186dd40e57ec1c38174be1db28dfd4c85c4.tar.gz
gitbook-868a3186dd40e57ec1c38174be1db28dfd4c85c4.tar.bz2
Add assertion to test that a file exists
-rw-r--r--package.json2
-rw-r--r--test/assertions.js11
-rw-r--r--test/helper.js3
-rw-r--r--test/json.js12
4 files changed, 22 insertions, 6 deletions
diff --git a/package.json b/package.json
index 5e77a72..51d6e14 100644
--- a/package.json
+++ b/package.json
@@ -45,7 +45,7 @@
"grunt-bower-install-simple": "0.9.2"
},
"scripts": {
- "test": "node_modules/.bin/mocha --reporter list --timeout 15000"
+ "test": "node_modules/.bin/mocha --reporter spec --timeout 15000"
},
"repository": {
"type": "git",
diff --git a/test/assertions.js b/test/assertions.js
new file mode 100644
index 0000000..b40a518
--- /dev/null
+++ b/test/assertions.js
@@ -0,0 +1,11 @@
+var fs = require('fs');
+var path = require('path');
+var should = require('should');
+
+should.Assertion.add('file', function(file, description) {
+ this.params = { operator: 'have file ' + file, message: description };
+
+ this.obj.should.have.property('options').which.is.an.Object;
+ this.obj.options.should.have.property('output').which.is.a.String;
+ this.assert(fs.existsSync(path.resolve(this.obj.options.output, file)));
+});
diff --git a/test/helper.js b/test/helper.js
index 5e65441..f0f1fb7 100644
--- a/test/helper.js
+++ b/test/helper.js
@@ -9,6 +9,9 @@ var fsUtil = require('../lib/utils/fs');
var Book = require('../').Book;
var LOG_LEVELS = require('../').LOG_LEVELS;
+require("./assertions");
+
+
var BOOKS = {};
var TMPDIR = os.tmpdir();
diff --git a/test/json.js b/test/json.js
index db4814b..7bebd4c 100644
--- a/test/json.js
+++ b/test/json.js
@@ -1,9 +1,11 @@
describe('JSON generator', function () {
- it('should correctly generate a basic book to json', function() {
- return books.generate("basic", "json")
- .then(function(book) {
-
- });
+ describe('Basic Book', function() {
+ it('should correctly output a README.json', function() {
+ return books.generate("basic", "json")
+ .then(function(book) {
+ book.should.have.file("README.json");
+ });
+ });
});
});