-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98c6be1
commit eeecc29
Showing
4 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
var gulp = require('gulp'); | ||
|
||
gulp.task('default', function () { | ||
console.log('default'); | ||
}); | ||
|
||
gulp.task('app', function () { | ||
console.log('app'); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
'use strict'; | ||
var spawn = require('child_process').spawn, | ||
path = require('path'); | ||
|
||
describe('slush', function () { | ||
it('should list installed generators', function (done) { | ||
var slush = runSlush(); | ||
var data = ''; | ||
slush.stdout.on('data', function (chunk) { | ||
data += chunk; | ||
}); | ||
slush.on('close', function (code) { | ||
code.should.equal(0); | ||
data.should.match(/\[slush\] ├── bad/); | ||
data.should.match(/\[slush\] └── test/); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should list tasks for given generator', function (done) { | ||
var slush = runSlush(['test', '--tasks']); | ||
var data = ''; | ||
slush.stdout.on('data', function (chunk) { | ||
data += chunk; | ||
}); | ||
slush.on('close', function (code) { | ||
code.should.equal(0); | ||
data.should.match(/\[gulp\] ├── default/); | ||
data.should.match(/\[gulp\] └── app/); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should run `default` task in generator, when task is not provided', function (done) { | ||
var slush = runSlush(['test']); | ||
var data = ''; | ||
slush.stdout.on('data', function (chunk) { | ||
data += chunk; | ||
}); | ||
slush.on('close', function (code) { | ||
code.should.equal(0); | ||
data.should.match(/\ndefault\n/); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should run provided task in generator', function (done) { | ||
var slush = runSlush(['test', 'app']); | ||
var data = ''; | ||
slush.stdout.on('data', function (chunk) { | ||
data += chunk; | ||
}); | ||
slush.on('close', function (code) { | ||
code.should.equal(0); | ||
data.should.match(/\napp\n/); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should fail when running a non-existing task in a generator', function (done) { | ||
var slush = runSlush(['test', 'noexist']); | ||
var data = ''; | ||
slush.stdout.on('data', function (chunk) { | ||
data += chunk; | ||
}); | ||
slush.on('close', function (code) { | ||
code.should.equal(1); | ||
data.should.match(/\[slush\] Task 'noexist' was not defined in `slush-test`/); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should fail when running a generator without slushfile', function (done) { | ||
var slush = runSlush(['bad']); | ||
var data = ''; | ||
slush.stdout.on('data', function (chunk) { | ||
data += chunk; | ||
}); | ||
slush.on('close', function (code) { | ||
code.should.equal(1); | ||
data.should.match(/\[slush\] No slushfile found/); | ||
data.should.match(/\[slush\].+issue with.+`slush-bad`/); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should fail trying to run a non-existing generator', function (done) { | ||
var slush = runSlush(['noexist']); | ||
var data = ''; | ||
slush.stdout.on('data', function (chunk) { | ||
data += chunk; | ||
}); | ||
slush.on('close', function (code) { | ||
code.should.equal(1); | ||
data.should.match(/\[slush\] No generator by name: "noexist" was found/); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
function runSlush (args) { | ||
args = args || []; | ||
var slush = spawn('node', [path.join(__dirname, '..', 'bin', 'slush.js')].concat(args), {cwd: __dirname}); | ||
slush.stdout.setEncoding('utf8'); | ||
return slush; | ||
} |