Skip to content

Commit

Permalink
Merge pull request #11 from benson/logical-and-tags
Browse files Browse the repository at this point in the history
Add ability to use logical AND for tags
  • Loading branch information
s9tpepper committed Mar 31, 2015
2 parents 04a2c27 + 72ef04f commit d843d84
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 8 deletions.
38 changes: 33 additions & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,36 @@ module.exports = function (grunt) {
}
},
cucumberjs: {
files: 'features',
options: {
steps: 'features/step_definitions',
format: 'pretty'
test1: {
files: 'features',
options: {
steps: 'features/step_definitions',
format: 'pretty'
}
},
test2: {
files: 'features/tags.feature',
options: {
steps: 'features/step_definitions',
format: 'pretty',
tags: '@tag'
}
},
test3: {
files: 'features/tags.feature',
options: {
steps: 'features/step_definitions',
format: 'pretty',
tags: ['@wip', '~@tag']
}
},
test4: {
files: 'features/tags.feature',
options: {
steps: 'features/step_definitions',
format: 'pretty',
tags: ['@wip', '@tag']
}
}
}
});
Expand All @@ -21,5 +47,7 @@ module.exports = function (grunt) {

grunt.loadTasks('tasks');

grunt.registerTask('default', ['jshint', 'cucumberjs']);
grunt.registerTask('default', ['jshint', 'cucumberjs:test1']);

grunt.registerTask('tag-tests', ['cucumberjs:test2', 'cucumberjs:test3', 'cucumberjs:test4'])
};
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ when this option is specified, and all loading becomes explicit.
Files under directories named "support" are always loaded first.

#### tags
Type: `String`
Type: `String` or `Array`

Default: `''`

Expand All @@ -58,6 +58,11 @@ this represents boolean NOT. Example:
by a comma, which represents logical OR. Example:
`tags: '@dev,@wip'`

To represent a logical AND, use an array.
This is useful if you want to skip certain features
and run other specific features. Example:
`tags: ['~@wip', '@dev']`

#### format
Type: `String`

Expand Down
27 changes: 27 additions & 0 deletions features/tags.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Feature: Testing tags
As a grunt-cucumber-js dev
I want a Testing.feature file with tags
So that I can test the tag functionality of cucumber-js-task

@wip
Scenario: Tagged wip
Given I have the number 1 and 3
When I add them together
Then I should have 4

@tag
Scenario: Tagged tag
Given I have the number 1 and 3
When I add them together
Then I should have 4

Scenario: No tags
Given I have the number 1 and 3
When I add them together
Then I should have 4

@wip @tag
Scenario: Tagged wip and tag
Given I have the number 1 and 3
When I add them together
Then I should have 4
9 changes: 7 additions & 2 deletions tasks/cucumber-js-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ module.exports = function (grunt) {
}

if (! _.isEmpty(tags)) {
execOptions.push('-t');
execOptions.push(tags);
if (typeof tags === "string") {
tags = [tags];
}
for (var i=0; i < tags.length; i++) {
execOptions.push('-t');
execOptions.push(tags[i]);
}
}

if (! _.isEmpty(format)) {
Expand Down

0 comments on commit d843d84

Please sign in to comment.