Skip to content

Commit

Permalink
re-adding scenario outline feature, cleaning up some steps, cleanin u…
Browse files Browse the repository at this point in the history
…p scenario outline and data table
  • Loading branch information
vantreeseba committed Feb 6, 2014
1 parent 77d4caf commit 084da1a
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 248 deletions.
103 changes: 61 additions & 42 deletions features/scenario_outlines.feature
@@ -1,51 +1,70 @@
Feature: Data Tables
Feature: Scenario Outlines and Examples

Scenario: a data table interpreted as an array
Given a scenario with:
"""
Given the following cukes:
| Cucumis sativus | Cucumber |
| Cucumis anguria | Burr Gherkin |
"""
And the step "the following cukes:" has a passing mapping that receives a data table
When Cucumber executes the scenario
Then the scenario passes
And the received data table array equals the following:
"""
[
[ "Cucumis sativus", "Cucumber" ],
[ "Cucumis anguria", "Burr Gherkin" ]
]
Scenario: Basic outline
Given the following feature:
"""
Feature: testing scenarios
Background:
Given a background step
Scenario: a data table can be read as an array of hashes
Given the following data table in a step:
Scenario Outline: outline
When a <some> step
Then i get <result>
Examples:
| some | result |
| passing | passed |
| failing | skipped |
"""
| Latin | English |
| Cucumis sativus | Cucumber |
| Cucumis anguria | Burr Gherkin |
#And the step "a background step" has a passing mapping
#And the step "a passing step" has a passing mapping
#And the step "a failing step" has a failing mapping
#And the step "i get passed" has a passing mapping
#And the step "i get skipped" has a passing mapping
When Cucumber runs the feature
Then the scenario called "outline" is reported as failing
#And the step "a background step" passes
#And the step "a passing step" passes
#And the step "a failing step" passes
#And the step "i get passed" passes
#And the step "i get skipped" is skipped

Scenario: Outline with table
Given the following feature:
"""
Feature: testing scenarios
Scenario Outline: outline
When a table step:
| first | second |
| <first> | <second> |
Examples:
| first | second |
| 1 | 2 |
"""
When the data table is passed to a step mapping that converts it to key/value pairs
Then the data table is converted to the following:
And the step "a table step:" has a passing mapping that receives a data table
When Cucumber runs the feature
Then the received data table array equals the following:
"""
[
{ "Latin":"Cucumis sativus", "English":"Cucumber" },
{ "Latin":"Cucumis anguria", "English":"Burr Gherkin" }
]
[["first","second"],["1","2"]]
"""

Scenario: a data table can be read as an array of values
Given the following data table in a step:
"""
| Latin | English |
| Cucumis sativus | Cucumber |
| Cucumis anguria | Burr Gherkin |
"""
When the data table is passed to a step mapping that gets the row arrays without the header
Then the data table is converted to the following:
Scenario: Outline with doc string
Given the following feature:
"""
Feature: testing scenarios
Scenario Outline: outline
When a doc sting step:
\"\"\"
I am doc string in <example> example
And there are <string> string
\"\"\"
Examples:
| example | string |
| first | some |
"""
[
[ "Cucumis sativus", "Cucumber" ],
[ "Cucumis anguria", "Burr Gherkin" ]
]
"""
And the step "a doc sting step:" has a passing mapping that receives a doc string
When Cucumber runs the feature
Then the received doc string equals the following:
"""
I am doc string in first example
And there are some string
"""
98 changes: 0 additions & 98 deletions features/step_definitions/cucumber_steps.js
Expand Up @@ -21,18 +21,6 @@ var cucumberSteps = function() {
this.addAroundHook(callback);
});

Given(/^an untagged hook$/, function(callback) {
this.addUntaggedHook(callback);
});

Given(/^a hook tagged with "([^"]*)"$/, function(tags, callback) {
this.addHookWithTags(tags, callback);
});

Given(/^an around hook tagged with "([^"]*)"$/, function(tags, callback) {
this.addAroundHookWithTags(tags, callback);
});

Given(/^the step "([^"]*)" has a failing mapping$/, function(stepName, callback) {
this.addFailingMapping(stepName, {}, callback);
});
Expand Down Expand Up @@ -119,31 +107,6 @@ setTimeout(callback.pending, 10);\
callback();
});

Given(/^a scenario without any tags$/, function(callback) {
this.addPassingScenarioWithoutTags();
callback();
});

Given(/^a scenario tagged with "([^"]*)"$/, function(tag, callback) {
this.addPassingScenarioWithTags(tag);
callback();
});

Given(/^a scenario tagged with "([^"]*)" and "([^"]*)"$/, function(tag1, tag2, callback) {
this.addPassingScenarioWithTags(tag1, tag2);
callback();
});

Given(/^a scenario tagged with "([^"]*)", "([^"]*)" and "([^"]*)"$/, function(tag1, tag2, tag3, callback) {
this.addPassingScenarioWithTags(tag1, tag2, tag3);
callback();
});

Given(/^a feature tagged with "([^"]*)"$/, function(tag, callback) {
this.createEmptyFeature({tags: [tag]});
callback();
});

Given(/^several features$/, function(callback) {
this.features = [
["feature1", "Feature: One\n\n Scenario:\n"],
Expand All @@ -157,10 +120,6 @@ setTimeout(callback.pending, 10);\
this.runFeature({}, callback);
});

When(/^Cucumber executes a scenario(?: with no tags)?$/, function(callback) {
this.runAScenario(callback);
});

this.When(/^Cucumber executes a scenario using that mapping$/, function(callback) {
this.runAScenarioCallingMapping(callback);
});
Expand All @@ -173,11 +132,6 @@ setTimeout(callback.pending, 10);\
this.runAScenarioCallingWorldFunction(callback);
});

When(/^Cucumber executes a scenario tagged with "([^"]*)"$/, function(tag, callback) {
this.addPassingScenarioWithTags(tag);
this.runFeature({}, callback);
});

When(/^Cucumber runs the feature$/, function(callback) {
this.runFeature({}, callback);
});
Expand Down Expand Up @@ -208,38 +162,6 @@ callback();\
this.runFeature({}, callback);
});

When(/^Cucumber executes scenarios tagged with "([^"]*)"$/, function(tag, callback) {
this.runFeature({tags: [tag]}, callback);
});

When(/^Cucumber executes scenarios not tagged with "([^"]*)"$/, function(tag, callback) {
this.runFeature({tags: ['~'+tag]}, callback);
});

When(/^Cucumber executes scenarios tagged with "([^"]*)" or "([^"]*)"$/, function(tag1, tag2, callback) {
this.runFeature({tags: [tag1 + ', ' + tag2]}, callback);
});

When(/^Cucumber executes scenarios tagged with both "([^"]*)" and "([^"]*)"$/, function(tag1, tag2, callback) {
this.runFeature({tags: [tag1, tag2]}, callback);
});

When(/^Cucumber executes scenarios not tagged with "([^"]*)" nor "([^"]*)"$/, function(tag1, tag2, callback) {
this.runFeature({tags: ['~'+tag1, '~'+tag2]}, callback);
});

When(/^Cucumber executes scenarios not tagged with both "([^"]*)" and "([^"]*)"$/, function(tag1, tag2, callback) {
this.runFeature({tags: ['~' + tag1 + ', ~' + tag2]}, callback);
});

When(/^Cucumber executes scenarios tagged with "([^"]*)" or without "([^"]*)"$/, function(tag1, tag2, callback) {
this.runFeature({tags: [tag1 + ', ~' + tag2]}, callback);
});

When(/^Cucumber executes scenarios tagged with "([^"]*)" but not with both "([^"]*)" and "([^"]*)"$/, function(tag1, tag2, tag3, callback) {
this.runFeature({tags: [tag1, '~' + tag2, '~' + tag3]}, callback);
});

Then(/^the scenario passes$/, function(callback) {
this.assertPassedScenario();
callback();
Expand Down Expand Up @@ -354,25 +276,5 @@ callback();\
this.assertCycleSequenceExcluding('hook');
callback();
});

Then(/^(?:only the first|the) scenario is executed$/, function(callback) {
this.assertExecutedNumberedScenarios(1);
callback();
});

Then(/^only the first two scenarios are executed$/, function(callback) {
this.assertExecutedNumberedScenarios(1, 2);
callback();
});

Then(/^only the third scenario is executed$/, function(callback) {
this.assertExecutedNumberedScenarios(3);
callback();
});

Then(/^only the second, third and fourth scenarios are executed$/, function(callback) {
this.assertExecutedNumberedScenarios(2, 3, 4);
callback();
});
};
module.exports = cucumberSteps;
47 changes: 47 additions & 0 deletions features/step_definitions/missing_steps.js
@@ -0,0 +1,47 @@
var missing_steps = function() {
var Given = When = Then = this.defineStep;
var World = require('./cucumber_world').World;
this.World = World;

this.Given(/^the step "([^"]*)" has a mapping asynchronously failing through an exception with the message "([^"]*)"$/, function (arg1, arg2, callback) {
// express the regexp above with the code you wish you had
callback.pending();
});

this.Then(/^it should pass with:$/, function (string, callback) {
// express the regexp above with the code you wish you had
callback.pending();
});

this.Given(/^a mapping written in CoffeeScript$/, function (callback) {
// express the regexp above with the code you wish you had
callback.pending();
});

this.Given(/^a mapping written in PogoScript$/, function (callback) {
// express the regexp above with the code you wish you had
callback.pending();
});

this.Then(/^a "([^"]*)" step definition snippet for \/\^I am a happy veggie \\\\o\\\/\$\/ is suggested$/, function (arg1, callback) {
// express the regexp above with the code you wish you had
callback.pending();
});

this.Then(/^a "([^"]*)" step definition snippet for \/\^I type \\\-\\\[\\\]\\\{\\\}\\\(\\\)\\\*\\\+\\\?\\\.\\\\\\\^\\\$\\\|\\\#\\\/\$\/ is suggested$/, function (arg1, callback) {
// express the regexp above with the code you wish you had
callback.pending();
});

this.Then(/^a "([^"]*)" step definition snippet for \/\^I have \(\\d\+\) "([^"]*)"\]\*\)" cucumbers\$\/ with (\d+) parameters is suggested$/, function (arg1, arg2, arg3, callback) {
// express the regexp above with the code you wish you had
callback.pending();
});

this.Then(/^a "([^"]*)" step definition snippet for \/\^I have some "([^"]*)"\]\*\)"([^"]*)"\(\[\^"([^"]*)" and "([^"]*)"\]\*\)" cucumbers\$\/ with (\d+) parameters is suggested$/, function (arg1, arg2, arg3, arg4, arg5, arg6, callback) {
// express the regexp above with the code you wish you had
callback.pending();
});

};
module.exports = missing_steps;
27 changes: 27 additions & 0 deletions features/step_definitions/scenario_execution_steps.js
@@ -0,0 +1,27 @@
var scenario_exection_steps = function() {
var Given = When = Then = this.defineStep;
var World = require('./cucumber_world').World;
this.World = World;


Then(/^(?:only the first|the) scenario is executed$/, function(callback) {
this.assertExecutedNumberedScenarios(1);
callback();
});

Then(/^only the first two scenarios are executed$/, function(callback) {
this.assertExecutedNumberedScenarios(1, 2);
callback();
});

Then(/^only the third scenario is executed$/, function(callback) {
this.assertExecutedNumberedScenarios(3);
callback();
});

Then(/^only the second, third and fourth scenarios are executed$/, function(callback) {
this.assertExecutedNumberedScenarios(2, 3, 4);
callback();
});
};
module.exports = scenario_exection_steps;

0 comments on commit 084da1a

Please sign in to comment.