Skip to content

Commit

Permalink
latest fixes and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Matriz88 committed Dec 14, 2016
1 parent e1b68c6 commit 2d6a074
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 29 deletions.
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ module.exports = {
steps_path: "./scripts/steps/common-steps",
components: {
enabled: true,
options: {
components_path: "./scripts/libs/components",
excludedComponents: ["component1", "component2"]
}
components_path: "./scripts/libs/components",
excludedComponents: ["component1", "component2"]
}
}
```
Expand All @@ -41,17 +39,17 @@ The file containing your steps definition.
####components (object | optional)
Components configurations.

If you use a file that exports a list of components used instead of css-selectors, for example:
If you use a file that exports a list of components used used for mapping css-selectors, for example:
```js
// example: components.js

module.exports {
_components: [
'component1',
'component2',
'component3',
'component4'
]
_components: {
'component1': 'body',
'component2': '.container',
'component3': '.container div',
'component4': '.footer a.link'
}
}
```
and your gherkin you have something like this:
Expand All @@ -65,8 +63,7 @@ Scenario:
```
then you should set `components.enable = true`.

####components.options
#####components_path (string | required if `components.enable = true`)
####components_path (string | required if `components.enable = true`)
The file containing your components definition.
#####excludedComponents (array | optional)
####excludedComponents (array | optional)
Array of components you want to skip in consistency check.
6 changes: 2 additions & 4 deletions config/default/default_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ module.exports = {
steps_path: "./steps/common-steps",
components: {
enabled: false,
options: {
components_path: "./components/components",
excludedComponents: []
}
components_path: "./components/components",
excludedComponents: []
}
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let stepsCache = [];
utils.readDirRecurs(path.resolve(global.cg_cofig.features_path), (err, data) => {
if (err) throw err;

tape('Check gherkin components', assert => {
tape('Check gherkin consistency', assert => {
data.forEach(file => {
let fileReadTask = utils.readFileAsync(file);
fileReadTask.then(data => {
Expand Down
8 changes: 4 additions & 4 deletions lib/test-core/checkComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ let path = require('path');
let checkIfExist = require('../utils/utilities').checkIfExist;

const componentPattern = /"(.*?)"/;
const Components = require(path.resolve(global.cg_cofig.components.options.components_path));
const Components = require(path.resolve(global.cg_cofig.components.components_path));
const components = Components._components;

module.exports = (step, assert) => {
Expand All @@ -12,11 +12,11 @@ module.exports = (step, assert) => {
if (matching === null) {
assert.skip("no components found in '" + step + "'");
} else {
if (global.cg_cofig.components.options.excludedComponents.indexOf(matching[1].toLowerCase()) > -1) {
if (global.cg_cofig.components.excludedComponents.indexOf(matching[1].toLowerCase()) > -1) {
assert.skip('skip excluded component "' + matching[1] + '"');
} else {
let comp = Components.get(matching[1]);
assert.equal(checkIfExist(comp.selector), 'found', '"' + matching[1] + '" component exists');
let comp = components[matching[1]];
assert.equal(checkIfExist(comp), 'found', '"' + matching[1] + '" component exists');
}
}
}
10 changes: 5 additions & 5 deletions lib/utils/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let Gherkin = require('gherkin');
let parser = new Gherkin.Parser();

/**
*
* read directory recursively and return and array of files found
* @param dir
* @param done
*/
Expand Down Expand Up @@ -33,7 +33,7 @@ let readDirRecurs = (dir, done) => {
exports.readDirRecurs = readDirRecurs;

/**
*
* read file asynchronously
* @param file
* @returns {Promise}
*/
Expand All @@ -47,17 +47,17 @@ exports.readFileAsync = (file) => {
}

/**
*
* check if the value is defined
* @param value
* @returns {*}
*/
exports.checkIfExist = (value) => {
if (value.length > 0) return 'found';
if (typeof value !== 'undefined') return 'found';
return 'not found'
}

/**
*
* given 'utf8' file content, return compiled gherkin
* @param data
*/
exports.getCompiledGherkin = (data) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gherkin-checker",
"version": "0.0.1",
"version": "1.0.0",
"private": true,
"scripts": {
"gherkin-checker": "tape ./index.js | tap-spec || exit 0"
Expand Down

0 comments on commit 2d6a074

Please sign in to comment.