Skip to content

Commit

Permalink
interceptors helpers 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
julio-saito-linx committed Sep 4, 2014
1 parent 31b8cd2 commit 5b98d2d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 250 deletions.
40 changes: 13 additions & 27 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,33 @@
var gulp = require('gulp');


var sources = ['*.js', 'src/**/*.js', '!gulpfile.js'];
var testSources = ['test/*.test.js'];
var allSources = sources.concat(testSources);

gulp.task('default', ['test', 'watch-mocha']);

gulp.task('test', ['cover', 'mocha']);
gulp.task('default', ['cover', 'watch']);

gulp.task('mocha', function() {
var mocha = require('gulp-mocha');
var gutil = require('gulp-util');

return gulp.src(testSources, { read: false })
.pipe( mocha( {
reporter: 'spec', growl: 'true'
} ))
.on('error', gutil.log);
gulp.task('watch', function() {
gulp.watch(allSources, ['cover']);
});

gulp.task('watch-mocha', function() {
gulp.watch(allSources, ['cover', 'mocha']);
});

// Run tests and output reports
gulp.task('cover', function (cb) {
gulp.task('cover', function () {
var mocha = require('gulp-mocha');
var gutil = require('gulp-util');
var istanbul = require('gulp-istanbul');

gulp.src(sources)
.pipe(istanbul()) // Covering files
return gulp.src(sources)
// Covering files
.pipe( istanbul() )
.on('finish', function () {
gulp.src(testSources)
.pipe(mocha())
.pipe( mocha({ reporter: 'spec', growl: 'true' }) )
.on('error', gutil.log) // prevent error to stop watch

.pipe(istanbul.writeReports()) // Creating the reports after tests runned
.on('end', cb);
;
});
});

gulp.task('start_cover', function (cb) {
var istanbul = require('gulp-istanbul');

gulp.src(sources)
.pipe(istanbul())
.on('end', cb);
});
8 changes: 4 additions & 4 deletions src/interceptors-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ var matchInterceptor = function(interceptor, methodName) {
return false;
};

var applyInterceptor = function(interceptorsObj, interceptor) {
return interceptor.callback(interceptorsObj.info);
var applyInfoToInterceptor = function(interceptor, infoObj) {
return interceptor.callback(infoObj);
};


Expand All @@ -71,7 +71,7 @@ var checkAndApplyInterceptor = function(interceptorsObj) {
}

if (interceptor) {
return applyInterceptor(interceptorsObj, interceptor);
return applyInfoToInterceptor(interceptor, interceptorsObj.info);
}
else {
return interceptorsObj.info.method;
Expand All @@ -83,6 +83,6 @@ module.exports = {
checkExistingInterceptors: checkExistingInterceptors,
selectInterceptor: selectInterceptor,
matchInterceptor: matchInterceptor,
applyInterceptor: applyInterceptor,
applyInfoToInterceptor: applyInfoToInterceptor,
checkAndApplyInterceptor: checkAndApplyInterceptor,
};
Loading

0 comments on commit 5b98d2d

Please sign in to comment.