summaryrefslogtreecommitdiffstats
path: root/spec/precompiler.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/precompiler.js')
-rw-r--r--spec/precompiler.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/precompiler.js b/spec/precompiler.js
new file mode 100644
index 0000000..10e2a2e
--- /dev/null
+++ b/spec/precompiler.js
@@ -0,0 +1,40 @@
+/*global shouldThrow */
+
+// NOP Under non-node environments
+if (typeof process === 'undefined') {
+ return;
+}
+
+var Handlebars = require('../lib'),
+ Precompiler = require('../lib/precompiler');
+
+describe('precompiler', function() {
+ var log,
+ logFunction;
+
+ beforeEach(function() {
+ logFunction = console.log;
+ log = '';
+ console.log = function() {
+ log += Array.prototype.join.call(arguments, '');
+ };
+ });
+ afterEach(function() {
+ console.log = logFunction;
+ });
+
+ it('should output version', function() {
+ Precompiler.cli({templates: [], version: true});
+ equals(log, Handlebars.VERSION);
+ });
+ it('should throw if lacking templates', function() {
+ shouldThrow(function() {
+ Precompiler.cli({templates: []});
+ }, Handlebars.Exception, 'Must define at least one template or directory.');
+ });
+ it('should throw on missing template', function() {
+ shouldThrow(function() {
+ Precompiler.cli({templates: ['foo']});
+ }, Handlebars.Exception, 'Unable to open template file "foo"');
+ });
+});