0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Refactoring tests to always run as expected

closes #721

- we now have grunt test-unit for safely running unit tests.
This commit is contained in:
Hannah Wolfe 2013-09-13 15:12:38 +01:00
parent 01f6551bf2
commit e9d2646997
3 changed files with 31 additions and 32 deletions

View file

@ -346,6 +346,11 @@ var path = require('path'),
grunt.initConfig(cfg);
grunt.registerTask('setTestEnv', function () {
// Use 'testing' Ghost config; unless we are running on travis (then show queries for debugging)
process.env.NODE_ENV = process.env.TRAVIS ? 'travis' : 'testing';
});
// Update the package information after changes
grunt.registerTask('updateCurrentPackageInfo', function () {
cfg.pkg = grunt.file.readJSON('package.json');
@ -383,28 +388,6 @@ var path = require('path'),
});
});
// Prepare the project for development
// TODO: Git submodule init/update (https://github.com/jaubourg/grunt-update-submodules)?
grunt.registerTask("init", ["shell:bourbon", "sass:admin", 'handlebars']);
// Run API tests only
grunt.registerTask("test-api", ["mochacli:api"]);
// Run permisisons tests only
grunt.registerTask("test-p", ["mochacli:perm"]);
// Run migrations tests only
grunt.registerTask("test-m", ["mochacli:migrate"]);
// Run casperjs tests only
grunt.registerTask('test-functional', ['express:test', 'spawn-casperjs']);
// Run tests and lint code
grunt.registerTask("validate", ["jslint", "mochacli:all", "test-functional"]);
// Generate Docs
grunt.registerTask("docs", ["groc"]);
/* Generate Changelog
* - Pulls changelog from git, excluding merges.
* - Uses first line of commit message. Includes committer name.
@ -698,6 +681,23 @@ var path = require('path'),
"watch"
]);
// Prepare the project for development
// TODO: Git submodule init/update (https://github.com/jaubourg/grunt-update-submodules)?
grunt.registerTask("init", ["shell:bourbon", "sass:admin", 'handlebars']);
// Run unit tests
grunt.registerTask("test-unit", ['setTestEnv', "mochacli:all"]);
// Run casperjs tests only
grunt.registerTask('test-functional', ['setTestEnv', 'express:test', 'spawn-casperjs']);
// Run tests and lint code
grunt.registerTask("validate", ["jslint", "mochacli:all", "test-functional"]);
// Generate Docs
grunt.registerTask("docs", ["groc"]);
// When you just say "grunt"
grunt.registerTask("default", ['sass:admin', 'handlebars']);
};

View file

@ -1,10 +1,12 @@
/*globals describe, beforeEach, it*/
var admin = require('../../server/controllers/admin'),
fs = require('fs-extra'),
var testUtils = require('./testUtils'),
should = require('should'),
sinon = require('sinon'),
when = require('when');
when = require('when'),
fs = require('fs-extra'),
// Stuff we are testing
admin = require('../../server/controllers/admin');
describe('Admin Controller', function() {
describe('uploader', function() {

View file

@ -1,6 +1,3 @@
// Use 'testing' Ghost config; unless we are running on travis (then show queries for debugging)
process.env.NODE_ENV = process.env.TRAVIS ? 'travis' : 'testing';
var knex = require('../../server/models/base').Knex,
when = require('when'),
migration = require("../../server/data/migration/"),