Skip to content
Permalink
Browse files
fixed jasmine custom matcher for toExist
  • Loading branch information
stevengill committed Jul 20, 2016
1 parent 6904ba9 commit bb90aa91267b5430d336f54ac43ab1e825cb87fd
Showing 4 changed files with 28 additions and 9 deletions.
@@ -39,7 +39,7 @@
"scripts": {
"test": "npm run jshint && npm run jasmine",
"jshint": "jshint index.js spec/create.spec.js",
"jasmine": "node node_modules/jasmine-node/bin/jasmine-node --color spec"
"jasmine": "jasmine spec/create.spec.js"
},
"contributors": [
{
@@ -71,7 +71,7 @@ var configNPM = {
}
};

describe('cordova create checks for valid-identifier', function(done) {
describe('cordova create checks for valid-identifier', function() {
it('should reject reserved words from start of id', function(done) {
create('projectPath', 'int.bob', 'appName')
.fail(function(err) {
@@ -148,16 +148,24 @@ module.exports.writeConfigContent = function (appPath, configContent) {

// Add the toExist matcher.
beforeEach(function () {
this.addMatchers({
jasmine.addMatchers({
'toExist': function () {
var notText = this.isNot ? ' not' : '';
var self = this;
return {
compare: function (testPath) {

this.message = function () {
return 'Expected file ' + self.actual + notText + ' to exist.';
};
var result = {};
result.pass = fs.existsSync(testPath);

return fs.existsSync(this.actual);
if(result.pass) {
result.message = 'Expected file ' + testPath + ' to exist.';
} else {
result.message = 'Expected file ' + testPath + ' to not exist.';
}

return result

}
}
}
});
});
@@ -0,0 +1,11 @@
{
"spec_dir": "spec",
"spec_files": [
"**/*[sS]pec.js"
],
"helpers": [
"helpers/**/*.js"
],
"stopSpecOnExpectationFailure": false,
"random": false
}

0 comments on commit bb90aa9

Please sign in to comment.