Skip to content

Instantly share code, notes, and snippets.

@ysaito8015
Forked from evan-007/gulpfile.js
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysaito8015/42966e31dea0e8122887 to your computer and use it in GitHub Desktop.
Save ysaito8015/42966e31dea0e8122887 to your computer and use it in GitHub Desktop.
var gulp = require('gulp');
var connect = require('gulp-connect');
var modRewrite = require('connect-modrewrite');
var runSequence = require('run-sequence');
var shell = require('gulp-shell');
//proxy all requests to /api to localhost:3000 for rails api
gulp.task('connect', function(){
connect.server({
root: './app',
port: 8000,
middleware: function() {
return [
modRewrite([
'^/api/v1/(.*)$ http://localhost:3000/api/v1/$1 [P]'
])
];
}
});
});
//start rails server daemon
gulp.task('rails-start', shell.task([
'rails s -d'
]));
gulp.task('rails-kill', shell.task([
"kill `cat ../tmp/pids/server.pid`"
]));
//resets rails dev DB with seed.db data
gulp.task('db-setup', shell.task([
'bundle exec rake db:setup'
]));
//runs e2e tests
gulp.task('protractor', shell.task([
'protractor protractorConfig.js'
]));
gulp.task('e2e-test', function(){
// start servers, setup test db,
// run e2e tests,
// reset db, kill rails daemon
runSequence('rails-start', 'connect', 'db-setup', 'protractor',
'db-setup', 'rails-kill')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment