Created
December 4, 2012 00:08
-
-
Save isao/4199250 to your computer and use it in GitHub Desktop.
minimal cli func test with shelljs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var assert = require('assert'), | |
shell = require('shelljs'), | |
path = require('path'), | |
BASEDIR = path.resolve(__dirname, '../') + '/', | |
NEWSAPP = BASEDIR + 'examples/newsboxes/'; | |
function test_version(exit, out) { | |
var expected_version = require(BASEDIR + 'package.json').version, | |
has_version = out.indexOf('Version of mojito is ' + expected_version); | |
assert.equal(0, exit); | |
assert.equal(true, has_version); | |
} | |
function test_version_app(exit, out) { | |
var expected = require(NEWSAPP + 'package.json').version, | |
actual = 'Version of application is 0.0.2'; | |
assert.equal(0, exit); | |
assert.equal('Version of application is ' + expected, actual); | |
} | |
function test_version_mojit_fail(exit, out) { | |
var expected = "✖ Error reading mojit version: ENOENT, no such file or directory '/Users/isao/Repos/mojito/myfork/examples/newsboxes/mojits/Read/package.json'\n✔ mojito done."; | |
assert.equal(0, exit); | |
assert.equal(expected, out.trim()); | |
} | |
function test_info(exit, out) { | |
var expected = "Name:\t\tmojito_newsboxes\nDescription:\ta developer oriented version of Ric Allinson's Slideboard\nVersion:\t0.0.2\n\n✔ mojito done."; | |
assert.equal(0, exit); | |
assert.equal(expected, out.trim()); | |
} | |
shell.exec('mojito version', test_version); | |
shell.cd(NEWSAPP); | |
shell.exec('mojito version app', test_version_app); | |
shell.exec('mojito version app ' + NEWSAPP, test_version_app); | |
shell.exec('mojito version mojit Read', test_version_mojit_fail); | |
shell.exec('mojito info', test_info); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment