-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,97 @@ | ||
var assert = require('chai').assert; | ||
var expect = require('chai').expect; | ||
var featureFinder = require('../../dist/feature-finder.js'); | ||
var mockFs = require('mock-fs'); | ||
|
||
describe('Feature finder', function() { | ||
beforeEach(function() { | ||
this.sinon.stub(console, 'error'); | ||
this.sinon.stub(process, 'exit'); | ||
mockFs({ | ||
'folder/with/found/features': { | ||
'a.feature': '', | ||
'folder': { 'b.feature': '' }, | ||
'c.txt': '' | ||
}, | ||
'../folder/with/unfound/features': { | ||
'd.feature': '', | ||
'e.txt': '' | ||
}, | ||
'feature': { | ||
'f.txt': '' | ||
} | ||
}); | ||
}); | ||
|
||
afterEach(function() { | ||
mockFs.restore(); | ||
console.error.restore(); // eslint-disable-line no-console | ||
process.exit.restore(); | ||
}); | ||
|
||
it('returns all feature files found recursively in the current directory when no path is passed to the command line', function() { | ||
var actual = featureFinder.getFeatureFiles([]); | ||
assert.deepEqual(actual, [ | ||
'folder/with/found/features/a.feature', | ||
'folder/with/found/features/folder/b.feature' | ||
]); | ||
}); | ||
|
||
it('returns all feature files in a directory and its subfolders when a "path/to/dir/**" pattern is used', function() { | ||
var actual = featureFinder.getFeatureFiles(['folder/with/found/features/**']); | ||
assert.deepEqual(actual, [ | ||
'folder/with/found/features/a.feature', | ||
'folder/with/found/features/folder/b.feature' | ||
]); | ||
}); | ||
|
||
it('returns all feature files in a directory when a "path/to/dir/*.feature" pattern is used', function() { | ||
var actual = featureFinder.getFeatureFiles(['folder/with/found/features/*.feature']); | ||
assert.deepEqual(actual, [ | ||
'folder/with/found/features/a.feature' | ||
]); | ||
}); | ||
|
||
it('returns all feature files in a directory and its subfolders when a path to a directory is used', function() { | ||
var actual = featureFinder.getFeatureFiles(['folder/with/found/features/']); | ||
assert.deepEqual(actual, [ | ||
'folder/with/found/features/a.feature', | ||
'folder/with/found/features/folder/b.feature' | ||
]); | ||
}); | ||
|
||
it('does not return duplicates', function() { | ||
var actual = featureFinder.getFeatureFiles([ | ||
'test/feature-finder/fixtures', | ||
'test/feature-finder' | ||
'folder/with/found/features/**', | ||
'path/to/fake/**' | ||
]); | ||
assert.deepEqual(actual, [ | ||
'folder/with/found/features/a.feature', | ||
'folder/with/found/features/folder/b.feature' | ||
]); | ||
assert.deepEqual(actual, ['test/feature-finder/fixtures/a.feature']); | ||
}); | ||
|
||
it('ignores files when the --ignore argument is provided', function() { | ||
var actual = featureFinder.getFeatureFiles(['test/feature-finder/**'], | ||
['test/feature-finder/**']); | ||
var actual = featureFinder.getFeatureFiles(['folder/with/found/features/**'], | ||
['folder/with/found/features/**']); | ||
assert.deepEqual(actual, []); | ||
}); | ||
|
||
it('ignores files in the .gherkin-lintignore', function() { | ||
featureFinder.defaultIgnoreFileName = 'test/feature-finder/fixtures/**'; | ||
var actual = featureFinder.getFeatureFiles(['test/feature-finder/**']); | ||
it('ignores files in the .gherkin-lintignore when specified as glob patterns', function() { | ||
mockFs({ | ||
'.gherkin-lintignore': | ||
'folder/with/found/features/a.feature\n\n..folder/with/found/features/**' | ||
}); | ||
var actual = featureFinder.getFeatureFiles(['folder/with/found/features/**']); | ||
assert.deepEqual(actual, []); | ||
}); | ||
|
||
it('prints an error message and exits with code 1 when a bad file pattern is used', function() { | ||
featureFinder.getFeatureFiles(['badpattern**']); | ||
var consoleErrorArgs = console.error.args.map(function (args) { // eslint-disable-line no-console | ||
return args[0]; | ||
}); | ||
expect(consoleErrorArgs[0]).to.include('Invalid format of the feature file path/pattern:'); | ||
expect(process.exit.args[0][0]).to.equal(1); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Empty file.