Skip to content

Commit

Permalink
Add test for folder with spaces in the name
Browse files Browse the repository at this point in the history
  • Loading branch information
mixu committed Dec 6, 2014
1 parent 15184ad commit f0787d4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 23 deletions.
3 changes: 0 additions & 3 deletions plugins/bootstrap.js

This file was deleted.

39 changes: 38 additions & 1 deletion test/gr.test.js
Expand Up @@ -51,12 +51,49 @@ describe('gr integration tests', function() {
run(fixturepath + '/a' + ' node ' +
utilpath + '/bin/echoback.js ' +
' "foo bar"', fixturepath + '/a', function(result) {
console.log(result);
assert.ok(/\[ 'foo bar' \]/.test(result));
done();
});
});

describe('path with spaces', function() {
var fixturepath = fs.realpathSync(fixture.dir({
'this path has spaces/file.txt': 'file.txt'
}));

it('can tag a folder using quotes', function(done) {
var tag = Math.random().toString(36).substring(2),
expected = fixturepath + '/this path has spaces';

run('--json +@' + tag + ' "' + expected + '"', fixturepath, function(result) {
// get the answer
run('--json tag ls ' + tag, fixturepath, function(result) {
assert.ok(Array.isArray(result));
assert.ok(result.some(function(v) {
return v == expected;
}));
done();
});
});
});

it('can tag a folder using escaped spaces', function(done) {
var tag = Math.random().toString(36).substring(2),
expected = fixturepath + '/this path has spaces';

run('--json +@' + tag + ' ' + expected.replace(/ /g, '\\ '), fixturepath, function(result) {
// get the answer
run('--json tag ls ' + tag, fixturepath, function(result) {
assert.ok(Array.isArray(result));
assert.ok(result.some(function(v) {
return v == expected;
}));
done();
});
});
});
});


// Not worth testing automatically:
// gr tag discover Auto-discover git paths under ~/
Expand Down
38 changes: 19 additions & 19 deletions test/integration.tagging.test.js
Expand Up @@ -29,21 +29,21 @@ describe('integration tagging', function() {
after(function() {
restore();
});

// Tagging:

describe('pristine - ', function() {

beforeEach(function(done) {
// add a new random tag
this.pristineTag = Math.random().toString(36).substring(2);
run('--json +#' + this.pristineTag, fixturepath + '/a', function(result) {
run('--json +@' + this.pristineTag, fixturepath + '/a', function(result) {
done();
});
});

it('#tag - List directories associated with "tag"', function(done) {
it('@tag - List directories associated with "tag"', function(done) {
var p = fixturepath + '/a';
// #foo
// @foo
run('--json -t ' + this.pristineTag, p, function(result) {
assert.ok(Array.isArray(result));
assert.ok(result.some(function(v) {
Expand All @@ -53,9 +53,9 @@ describe('integration tagging', function() {
});
});

// #tag <cmd> Run a command in the directories associated with "tag"
// @tag <cmd> Run a command in the directories associated with "tag"
it('-t <tag> <cmd> - Run a command in the directories associated with "tag"', function(done) {
// #foo ls -lah
// @foo ls -lah
run('-t ' + this.pristineTag + ' ls -lah', fixturepath + '/a', function(result) {
// check that one of the lines contains "a.txt"
assert.ok(/a\.txt/.test(result));
Expand Down Expand Up @@ -87,12 +87,12 @@ describe('integration tagging', function() {
});
});

it('-#tag - Remove a tag from the current directory (cwd)', function(done) {
it('-@tag - Remove a tag from the current directory (cwd)', function(done) {
var p = fixturepath + '/a',
tag = this.pristineTag;
// -#foo
// -@foo
// tag rm foo
run('--json -#' + tag, p, function(result) {
run('--json -@' + tag, p, function(result) {
assert.deepEqual(result, { op: 'rm', tag: tag, path: p });
run('--json tag ls ' + tag, p, function(result) {
assert.ok(Array.isArray(result));
Expand All @@ -104,7 +104,7 @@ describe('integration tagging', function() {
});
});

it('tag rm <tag> - Alternative to -#tag', function(done) {
it('tag rm <tag> - Alternative to -@tag', function(done) {
var p = fixturepath + '/b',
tag = this.pristineTag;
run('--json tag rm ' + tag, p, function(result) {
Expand All @@ -116,10 +116,10 @@ describe('integration tagging', function() {
});


it('+#tag - Add a tag to the current directory (cwd)', function(done) {
it('+@tag - Add a tag to the current directory (cwd)', function(done) {
var p = fixturepath + '/a',
tag = Math.random().toString(36).substring(2);
run('--json +#' + tag, p, function(result) {
run('--json +@' + tag, p, function(result) {
// get the answer
run('--json tag ls ' + tag, p, function(result) {
assert.ok(Array.isArray(result));
Expand All @@ -131,7 +131,7 @@ describe('integration tagging', function() {
});
});

it('tag add <tag> - Alternative to +#tag (cwd)', function(done) {
it('tag add <tag> - Alternative to +@tag (cwd)', function(done) {
var p = fixturepath + '/b',
tag = Math.random().toString(36).substring(2);
run('--json tag add ' + tag, p, function(result) {
Expand All @@ -157,10 +157,10 @@ describe('integration tagging', function() {
this.pristineTag = Math.random().toString(36).substring(2);
});

it('+#tag <p1> <p2> ... Add a tag to <path>', function(done) {
it('+@tag <p1> <p2> ... Add a tag to <path>', function(done) {
var self = this,
p = fixturepath + '/a';
run('--json +#' + this.pristineTag + ' ' + this.dirs.join(' '), p, function(result) {
run('--json +@' + this.pristineTag + ' ' + this.dirs.join(' '), p, function(result) {
// get the answer
run('--json tag ls ' + self.pristineTag, p, function(result) {

Expand All @@ -174,7 +174,7 @@ describe('integration tagging', function() {
});
});

it('tag add <t> <p1> <p2> ... Alternative to +#tag <path>', function(done) {
it('tag add <t> <p1> <p2> ... Alternative to +@tag <path>', function(done) {
var self = this,
p = fixturepath + '/a';
run('--json tag add ' + this.pristineTag + ' ' + this.dirs.join(' '), p, function(result) {
Expand All @@ -190,11 +190,11 @@ describe('integration tagging', function() {
});
});

// -#tag <path> Remove a tag from <path>
// tag rm <t> <p> Alternative to -#tag <path>
// -@tag <path> Remove a tag from <path>
// tag rm <t> <p> Alternative to -@tag <path>
// TODO

// gr -#foo path1 path2 path3
// gr -@foo path1 path2 path3
// TODO

});
Expand Down

0 comments on commit f0787d4

Please sign in to comment.