Update railwayjs name, add ability to skip tests

This commit is contained in:
Anatoliy Chakkaev 2012-12-19 18:57:21 +04:00
parent 262c618040
commit acc0a71bde
2 changed files with 17 additions and 6 deletions

View File

@ -11,7 +11,7 @@ if (global.railway) {
module.exports = function init(root) { module.exports = function init(root) {
var railway, app, models; var railway, app, models;
if (typeof root !== 'object' || root.constructor.name !== 'Railway') { if (typeof root !== 'object' || root.constructor.name !== 'Compound') {
railway = global.railway; railway = global.railway;
app = global.app; app = global.app;
models = app.models; models = app.models;

View File

@ -33,6 +33,10 @@ function it(name, cases) {
batch[schemaName][name] = cases; batch[schemaName][name] = cases;
} }
function skip(name) {
delete batch[schemaName][name];
}
module.exports = function testSchema(exportCasesHere, schema) { module.exports = function testSchema(exportCasesHere, schema) {
batch = exportCasesHere; batch = exportCasesHere;
@ -69,7 +73,6 @@ module.exports = function testSchema(exportCasesHere, schema) {
}; };
module.exports.it = it;
Object.defineProperty(module.exports, 'it', { Object.defineProperty(module.exports, 'it', {
writable: true, writable: true,
enumerable: false, enumerable: false,
@ -77,6 +80,13 @@ Object.defineProperty(module.exports, 'it', {
value: it value: it
}); });
Object.defineProperty(module.exports, 'skip', {
writable: true,
enumerable: false,
configurable: true,
value: skip
});
function testOrm(schema) { function testOrm(schema) {
var requestsAreCounted = schema.name !== 'mongodb'; var requestsAreCounted = schema.name !== 'mongodb';
@ -101,7 +111,7 @@ function testOrm(schema) {
subject: { type: String }, subject: { type: String },
content: { type: Text }, content: { type: Text },
date: { type: Date, default: function () { return new Date }, index: true }, date: { type: Date, default: function () { return new Date }, index: true },
published: { type: Boolean, default: false }, published: { type: Boolean, default: false, index: true },
likes: [], likes: [],
related: [RelatedPost] related: [RelatedPost]
}, {table: 'posts'}); }, {table: 'posts'});
@ -445,9 +455,10 @@ function testOrm(schema) {
it('should find records filtered with multiple attributes', function (test) { it('should find records filtered with multiple attributes', function (test) {
Post.create({title: 'title', content: 'content', published: true, date: 1}, function (err, post) { var d = new Date;
Post.all({where: {title: 'title', date: 1}}, function (err, res) { Post.create({title: 'title', content: 'content', published: true, date: d}, function (err, post) {
test.ok(res.length > 0, 'Exact match with string returns dataset'); Post.all({where: {title: 'title', date: d, published: true}}, function (err, res) {
test.equals(res.length, 1, 'Filtering Posts returns one post');
test.done(); test.done();
}); });
}); });