switch specs

This commit is contained in:
Peter Cottle 2013-10-29 10:00:52 -07:00
parent 7bbc81de97
commit 1bd2f5de64
2 changed files with 31 additions and 20 deletions

View file

@ -4,9 +4,18 @@ var HeadlessGit = require('../src/js/git/headless').HeadlessGit;
var fs = require('fs'); var fs = require('fs');
prompt = require('prompt'); prompt = require('prompt');
function getFile(truthy) {
var filename = (truthy) ?
'./remote.spec.js' :
'./git.spec.js';
return fs.readFileSync(filename, 'utf8');
}
prompt.start(); prompt.start();
prompt.get(['command', 'whatItDoes'], function(err, result) { prompt.get(
['command', 'whatItDoes', 'intoGitSpec'],
function(err, result) {
var headless = new HeadlessGit(); var headless = new HeadlessGit();
headless.sendCommand(result.command); headless.sendCommand(result.command);
setTimeout(function() { setTimeout(function() {
@ -17,7 +26,7 @@ prompt.get(['command', 'whatItDoes'], function(err, result) {
console.log(testCase); console.log(testCase);
// now add it // now add it
var testFile = fs.readFileSync('./remote.spec.js', 'utf8'); var testFile = getFile(result.intoGitSpec);
// insert after the last }) // insert after the last })
var toSlice = testFile.lastIndexOf('})'); var toSlice = testFile.lastIndexOf('})');
var partOne = testFile.slice(0, toSlice); var partOne = testFile.slice(0, toSlice);
@ -27,5 +36,6 @@ prompt.get(['command', 'whatItDoes'], function(err, result) {
testCase + "\t});\n\n"; testCase + "\t});\n\n";
fs.writeFileSync('./remote.spec.js', partOne + funcCall + partTwo); fs.writeFileSync('./remote.spec.js', partOne + funcCall + partTwo);
}, 100); }, 100);
}); }
);

View file

@ -155,5 +155,6 @@ describe('Git', function() {
'{"branches":{"master":{"target":"C5","id":"master","remoteTrackingBranchID":null},"side":{"target":"C4","id":"side","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C1"],"id":"C3"},"C4":{"parents":["C2","C3"],"id":"C4"},"C5":{"parents":["C2","C4"],"id":"C5"}},"HEAD":{"target":"master","id":"HEAD"}}' '{"branches":{"master":{"target":"C5","id":"master","remoteTrackingBranchID":null},"side":{"target":"C4","id":"side","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C1"],"id":"C3"},"C4":{"parents":["C2","C3"],"id":"C4"},"C5":{"parents":["C2","C4"],"id":"C5"}},"HEAD":{"target":"master","id":"HEAD"}}'
); );
}); });
}); });