Skip to content

Commit

Permalink
add tests + docs for hulk
Browse files Browse the repository at this point in the history
remove gh-pages dir
  • Loading branch information
fat committed Apr 6, 2012
1 parent 4c6557c commit a09770b
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 11 deletions.
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -8,6 +8,12 @@ VERSION = ${shell node -e 'console.log(JSON.parse(require("fs").readFileSync("pa
test:
@ node test/run.js test/index.html

#
# Run hulk tests
#
hulk:
@ node test/hulk.js

#
# Run Mustache spec tests
#
Expand Down
20 changes: 11 additions & 9 deletions bin/hulk
Expand Up @@ -15,13 +15,15 @@
* limitations under the License.
*/

var hogan = require('../lib/hogan.js'),
path = require('path'),
fs = require('fs');
// dependencies
var hogan = require('../lib/hogan.js')
, path = require('path')
, fs = require('fs');

var specials = ['/', '.', '*', '+', '?', '|','(', ')', '[', ']', '{', '}', '\\'],
specialsRegExp = new RegExp('(\\' + specials.join('|\\') + ')', 'g'),
templates;
// locals
var specials = ['/', '.', '*', '+', '?', '|','(', ')', '[', ']', '{', '}', '\\']
, specialsRegExp = new RegExp('(\\' + specials.join('|\\') + ')', 'g')
, templates;


// Escape special regexp characters
Expand All @@ -32,13 +34,13 @@ function esc(text) {

// Check for dirs and correct ext (<3 for windows)
function extractFiles(args) {
var usage = 'USAGE: hulk ./templates/*.mustaches\n' +
'NOTE: hulk supports the "*" wildcard and allows you to target specific extensions too',
var usage = '\033[36mUSAGE:\033[39m hulk ./templates/*.mustaches\n' +
'\033[36mNOTE:\033[39m hulk supports the "*" wildcard and allows you to target specific extensions too',
files = [];

if (!args.length) {
console.log(usage);
process.exit(-1);
process.exit(0);
}

args.forEach(function (arg) {
Expand Down
42 changes: 42 additions & 0 deletions test/hulk.js
@@ -0,0 +1,42 @@
var exec = require('child_process').exec
, assert = require('assert')
, Hogan = require('../lib/hogan.js');


// help text
exec('node bin/hulk', function (error, stdout, stderr) {
if (error) throw error;
assert(typeof stdout == 'string', 'it should have help text.');
assert(/USAGE/.test(stdout), 'has USAGE text');
assert(/NOTE/.test(stdout), 'has NOTE text about wildcard');
})

// templates wildcard
exec('node bin/hulk test/templates/*', function (error, stdout, stderr) {
if (error) throw error;
eval(stdout);
assert(typeof templates == 'object', 'defineed a templates object');
assert(typeof templates.list == 'object', 'defined a templates.list object');
assert(typeof templates.list.r == 'function', 'defined a templates.list.r function');
assert(templates.list.r() == '<ul>\n<li></li>\n<li></li>\n<li></li>\n<li></li>\n<li></li>\n<li></li>\n</ul>')
});

// templates wildcard w/ extension
exec('node bin/hulk test/templates/*.mustache', function (error, stdout, stderr) {
if (error) throw error;
eval(stdout);
assert(typeof templates == 'object', 'defineed a templates object');
assert(typeof templates.list == 'object', 'defined a templates.list object');
assert(typeof templates.list.r == 'function', 'defined a templates.list.r function');
assert(templates.list.r() == '<ul>\n<li></li>\n<li></li>\n<li></li>\n<li></li>\n<li></li>\n<li></li>\n</ul>')
});

// templates single file
exec('node bin/hulk test/templates/list.mustache', function (error, stdout, stderr) {
if (error) throw error;
eval(stdout);
assert(typeof templates == 'object', 'defineed a templates object');
assert(typeof templates.list == 'object', 'defined a templates.list object');
assert(typeof templates.list.r == 'function', 'defined a templates.list.r function');
assert(templates.list.r() == '<ul>\n<li></li>\n<li></li>\n<li></li>\n<li></li>\n<li></li>\n<li></li>\n</ul>')
});
22 changes: 20 additions & 2 deletions web/index.html.mustache
Expand Up @@ -117,6 +117,26 @@
<div class="ten columns offset-by-one">
<script src="https://gist.github.com/1575714.js"> </script>
</div>
<div class="hogan-divider">
<div class="hogan-icon"></div>
</div>


<!-- Layout 5 -->
<div class="five columns">
<h4 id='rendering'>Hulk</h4>
<p>
Hulk is Hogan's command line utility. Use it to easily compile your templates as js files.
</p>
<p>
Hulk supports the <code>*</code> wilcard (even on windows) and allows you to target specific file extensions as well.</p>
<p>
</p>
</div>

<div class="ten columns offset-by-one">
<script src="https://gist.github.com/2322961.js"> </script>
</div>

<div class="sixteen columns hogan-footer">
<span class="copyright">
Expand All @@ -128,8 +148,6 @@
</span>
</div>



</div><!-- container -->


Expand Down

0 comments on commit a09770b

Please sign in to comment.