From 443087051d62eb8a0958ffe606ec5199c7c20f89 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 7 Sep 2015 18:24:09 +0300 Subject: [PATCH 1/3] Fix tests always passing should.true and should.false are functions so needed to be should.true() and should.false() --- test/index.js | 78 +++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/test/index.js b/test/index.js index de2ad2c..78871d5 100644 --- a/test/index.js +++ b/test/index.js @@ -20,88 +20,88 @@ describe('gitignore parser', function () { describe('accepts()', function () { it('should accept the given filenames', function () { - this.gitignore.accepts('test/index.js').should.be.true; - this.gitignore.accepts('wat/test/index.js').should.be.true; - this.gitignoreNoNegatives.accepts('test/index.js').should.be.true; + this.gitignore.accepts('test/index.js').should.be.true(); + this.gitignore.accepts('wat/test/index.js').should.be.true(); + this.gitignoreNoNegatives.accepts('test/index.js').should.be.true(); }); it('should not accept the given filenames', function () { - this.gitignore.accepts('test.swp').should.be.false; - this.gitignore.accepts('node_modules/wat.js').should.be.false; - this.gitignore.accepts('foo/bar.wat').should.be.false; - this.gitignoreNoNegatives.accepts('node_modules/wat.js').should.be.false; + this.gitignore.accepts('test.swp').should.be.false(); + this.gitignore.accepts('node_modules/wat.js').should.be.false(); + this.gitignore.accepts('foo/bar.wat').should.be.false(); + this.gitignoreNoNegatives.accepts('node_modules/wat.js').should.be.false(); }); it('should not accept the given directory', function () { - this.gitignore.accepts('nonexistent').should.be.false; - this.gitignore.accepts('nonexistent/bar').should.be.false; - this.gitignoreNoNegatives.accepts('node_modules').should.be.false; + this.gitignore.accepts('nonexistent').should.be.false(); + this.gitignore.accepts('nonexistent/bar').should.be.false(); + this.gitignoreNoNegatives.accepts('node_modules').should.be.false(); }); it('should accept unignored files in ignored directories', function () { - this.gitignore.accepts('nonexistent/foo').should.be.true; + this.gitignore.accepts('nonexistent/foo').should.be.true(); }); it('should accept nested unignored files in ignored directories', function () { - this.gitignore.accepts('nonexistent/foo/wat').should.be.true; + this.gitignore.accepts('nonexistent/foo/wat').should.be.true(); }); }); describe('denies()', function () { it('should deny the given filenames', function () { - this.gitignore.denies('test.swp').should.be.true; - this.gitignore.denies('node_modules/wat.js').should.be.true; - this.gitignore.denies('foo/bar.wat').should.be.true; - this.gitignoreNoNegatives.denies('node_modules/wat.js').should.be.true; + this.gitignore.denies('test.swp').should.be.true(); + this.gitignore.denies('node_modules/wat.js').should.be.true(); + this.gitignore.denies('foo/bar.wat').should.be.true(); + this.gitignoreNoNegatives.denies('node_modules/wat.js').should.be.true(); }); it('should not deny the given filenames', function () { - this.gitignore.denies('test/index.js').should.be.false; - this.gitignore.denies('wat/test/index.js').should.be.false; - this.gitignoreNoNegatives.denies('test/index.js').should.be.false; - this.gitignoreNoNegatives.denies('wat/test/index.js').should.be.false; + this.gitignore.denies('test/index.js').should.be.false(); + this.gitignore.denies('wat/test/index.js').should.be.false(); + this.gitignoreNoNegatives.denies('test/index.js').should.be.false(); + this.gitignoreNoNegatives.denies('wat/test/index.js').should.be.false(); }); it('should deny the given directory', function () { - this.gitignore.denies('nonexistent').should.be.true; - this.gitignore.denies('nonexistent/bar').should.be.true; - this.gitignoreNoNegatives.denies('node_modules').should.be.true; - this.gitignoreNoNegatives.denies('node_modules/foo').should.be.true; + this.gitignore.denies('nonexistent').should.be.true(); + this.gitignore.denies('nonexistent/bar').should.be.true(); + this.gitignoreNoNegatives.denies('node_modules').should.be.true(); + this.gitignoreNoNegatives.denies('node_modules/foo').should.be.true(); }); it('should not deny unignored files in ignored directories', function () { - this.gitignore.denies('nonexistent/foo').should.be.false; + this.gitignore.denies('nonexistent/foo').should.be.false(); }); it('should not deny nested unignored files in ignored directories', function () { - this.gitignore.denies('nonexistent/foo/wat').should.be.false; + this.gitignore.denies('nonexistent/foo/wat').should.be.false(); }); }); describe('maybe()', function () { it('should return true for directories not mentioned by .gitignore', function () { - this.gitignore.maybe('lib').should.be.true; - this.gitignore.maybe('lib/foo/bar').should.be.true; - this.gitignoreNoNegatives.maybe('lib').should.be.true; - this.gitignoreNoNegatives.maybe('lib/foo/bar').should.be.true; + this.gitignore.maybe('lib').should.be.true(); + this.gitignore.maybe('lib/foo/bar').should.be.true(); + this.gitignoreNoNegatives.maybe('lib').should.be.true(); + this.gitignoreNoNegatives.maybe('lib/foo/bar').should.be.true(); }); it('should return false for directories explicitly mentioned by .gitignore', function () { - this.gitignore.maybe('baz').should.be.false; - this.gitignore.maybe('baz/wat/foo').should.be.false; - this.gitignoreNoNegatives.maybe('node_modules').should.be.false; + this.gitignore.maybe('baz').should.be.false(); + this.gitignore.maybe('baz/wat/foo').should.be.false(); + this.gitignoreNoNegatives.maybe('node_modules').should.be.false(); }); it('should return true for ignored directories that have exceptions', function () { - this.gitignore.maybe('nonexistent').should.be.true; - this.gitignore.maybe('nonexistent/foo').should.be.true; - this.gitignore.maybe('nonexistent/foo/bar').should.be.true; + this.gitignore.maybe('nonexistent').should.be.true(); + this.gitignore.maybe('nonexistent/foo').should.be.true(); + this.gitignore.maybe('nonexistent/foo/bar').should.be.true(); }); it('should return false for non exceptions of ignored subdirectories', function () { - this.gitignore.maybe('nonexistent/wat').should.be.false; - this.gitignore.maybe('nonexistent/wat/foo').should.be.false; - this.gitignoreNoNegatives.maybe('node_modules/wat/foo').should.be.false; + this.gitignore.maybe('nonexistent/wat').should.be.false(); + this.gitignore.maybe('nonexistent/wat/foo').should.be.false(); + this.gitignoreNoNegatives.maybe('node_modules/wat/foo').should.be.false(); }); }); }); From eeb23b65eb86195a0dafa580efe8edfe64678e53 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 7 Sep 2015 18:50:04 +0300 Subject: [PATCH 2/3] *.swp pattern should also apply to all subfolders --- test/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/index.js b/test/index.js index 78871d5..d8a02cf 100644 --- a/test/index.js +++ b/test/index.js @@ -27,6 +27,7 @@ describe('gitignore parser', function () { it('should not accept the given filenames', function () { this.gitignore.accepts('test.swp').should.be.false(); + this.gitignore.accepts('foo/test.swp').should.be.false(); this.gitignore.accepts('node_modules/wat.js').should.be.false(); this.gitignore.accepts('foo/bar.wat').should.be.false(); this.gitignoreNoNegatives.accepts('node_modules/wat.js').should.be.false(); @@ -50,6 +51,7 @@ describe('gitignore parser', function () { describe('denies()', function () { it('should deny the given filenames', function () { this.gitignore.denies('test.swp').should.be.true(); + this.gitignore.denies('foo/test.swp').should.be.true(); this.gitignore.denies('node_modules/wat.js').should.be.true(); this.gitignore.denies('foo/bar.wat').should.be.true(); this.gitignoreNoNegatives.denies('node_modules/wat.js').should.be.true(); From f74c300e2f1c43f4c500056388a155730bdbdd9a Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 7 Sep 2015 18:56:49 +0300 Subject: [PATCH 3/3] Add test for issue #9 - pattern matching is too greedy --- test/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/index.js b/test/index.js index d8a02cf..a07bac1 100644 --- a/test/index.js +++ b/test/index.js @@ -23,6 +23,7 @@ describe('gitignore parser', function () { this.gitignore.accepts('test/index.js').should.be.true(); this.gitignore.accepts('wat/test/index.js').should.be.true(); this.gitignoreNoNegatives.accepts('test/index.js').should.be.true(); + this.gitignoreNoNegatives.accepts('node_modules.json').should.be.true(); }); it('should not accept the given filenames', function () { @@ -62,6 +63,7 @@ describe('gitignore parser', function () { this.gitignore.denies('wat/test/index.js').should.be.false(); this.gitignoreNoNegatives.denies('test/index.js').should.be.false(); this.gitignoreNoNegatives.denies('wat/test/index.js').should.be.false(); + this.gitignoreNoNegatives.denies('node_modules.json').should.be.false(); }); it('should deny the given directory', function () {