Skip to content

Commit

Permalink
test(bump): add tests for version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
kevva committed Apr 16, 2013
1 parent f10a0c4 commit 6882259
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 19 deletions.
53 changes: 40 additions & 13 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
module.exports = function(grunt){

grunt.loadTasks('tasks');

module.exports = function(grunt) {
grunt.initConfig({
clean: {
test: 'test/fixtures/_component.json'
},
nodeunit: {
tests: 'test/release_test.js'
},
release: {
options: {
// bump: true,
// file: 'test-component.json',
// add: false,
// commit: false,
// tag: false,
// push: false,
// pushTags: false,
// npm: false,
bump: true,
file: 'test/fixtures/_component.json',
add: false,
commit: false,
tag: false,
push: false,
pushTags: false,
npm: false
}
},
setup: {
test: {
src: 'test/fixtures/component.json',
dest: 'test/fixtures/_component.json'
}
}
});
};

grunt.loadTasks('tasks');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-nodeunit');

grunt.registerTask('test', [
'clean',
'setup',
'release',
'nodeunit',
'clean'
]);

grunt.registerMultiTask('setup', 'Setup fixtures', function(){
this.files.forEach(function(f){
grunt.file.copy(f.src, f.dest);
});
});
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Release a new version of your Node-based project",
"main": "Gruntfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "grunt test"
},
"repository": {
"type": "git",
Expand All @@ -24,7 +24,9 @@
"semver": "~1.1.4"
},
"devDependencies": {
"grunt": "~0.4.0"
"grunt": "~0.4.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-nodeunit": "~0.1.2"
},
"peerDependencies": {
"grunt": "~0.4.1"
Expand Down
4 changes: 0 additions & 4 deletions test-component.json

This file was deleted.

4 changes: 4 additions & 0 deletions test/expected/component.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "grunt-release-test",
"version": "0.0.13"
}
4 changes: 4 additions & 0 deletions test/fixtures/component.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "grunt-release-test",
"version": "0.0.12"
}
13 changes: 13 additions & 0 deletions test/release_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var grunt = require('grunt');

exports.release = {
bump: function(test){
test.expect(1);

var actual = grunt.file.readJSON('test/fixtures/_component.json');
var expected = grunt.file.readJSON('test/expected/component.json');
test.equal(actual.version, expected.version, 'should set version 0.0.13');

test.done();
}
};

0 comments on commit 6882259

Please sign in to comment.