Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scenario outlines redux #155

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
016df31
[+] Added step definitions and examples
hairyhum May 27, 2012
e437a70
[*] Prepared UIA version
hairyhum May 30, 2012
db6d9c5
[*] Scenarios and outlines events
hairyhum May 30, 2012
f8b27ea
outline fix
hairyhum May 30, 2012
d563a1d
[*] Changed example row reporting
hairyhum Jun 1, 2012
fc08ef8
[*] witnessNewScenario every example row
hairyhum Jun 4, 2012
9965ff9
[*] Fixing some collection calls
hairyhum Jun 8, 2012
d940ac2
[+] added cucumber tests for scenarios and outlines
hairyhum Jun 9, 2012
7699725
[*] Added scenario outline test
hairyhum Jun 9, 2012
09c25ee
[+] Fixing index
hairyhum Jun 27, 2012
1967b21
[+] Prepared for pull request
hairyhum Jun 27, 2012
b013d39
trying to merge in master
vantreeseba Feb 5, 2014
77d4caf
trying to get scenario outlines working
vantreeseba Feb 5, 2014
084da1a
re-adding scenario outline feature, cleaning up some steps, cleanin u…
vantreeseba Feb 6, 2014
d993e88
commenting out failing features
vantreeseba Feb 6, 2014
323500a
Fixing jasmine specs for ast_tree_walker visiting scenarios
Feb 6, 2014
25269b7
trying to get to the bottom of stack overflow error
Feb 6, 2014
f8b8d35
got all scenario_outline.feature passing
vantreeseba Feb 7, 2014
5168174
started on scenario_outline specs, and finished example_specs
vantreeseba Feb 7, 2014
f3659a3
more specs on scenario outline
vantreeseba Feb 7, 2014
3ba5088
basic scenario outline functionality completed
Feb 8, 2014
8d4439e
Added better suggestion output for missing scenario outline steps
Feb 8, 2014
8359996
adding back steps
Feb 8, 2014
afdf537
making current tests pass
vantreeseba Feb 8, 2014
d10585d
adding specs for outline_step and changes to step
vantreeseba Feb 8, 2014
17715a5
cleaning up steps a little, cleaning up assembler functions for scena…
vantreeseba Feb 8, 2014
ed2812d
adding more assembler tests
vantreeseba Feb 8, 2014
4a39f81
removing stupid .orig files
vantreeseba Feb 8, 2014
f4803c6
adding bundler install step to travis.yml
vantreeseba Feb 8, 2014
65039bd
apparently sudo install is wrong on travis gems :P
vantreeseba Feb 8, 2014
28ce292
changing name of stored scenarios in feature to feature elements
vantreeseba Feb 10, 2014
35a5462
renaming scenarios parts of feature to featureElements
vantreeseba Feb 10, 2014
aa471b3
making buildScenarios 'polymorphic'
vantreeseba Feb 10, 2014
1cd669c
changing payload_type to payloadType
vantreeseba Feb 10, 2014
28224ef
fixing specs on payloadType
vantreeseba Feb 10, 2014
60b437c
trying to get bundler installed globally for rvm.
vantreeseba Feb 10, 2014
d8efad6
cleaning up travis to remove trying to install bundler, actually impl…
vantreeseba Feb 11, 2014
bc7b840
removing step_definition_snippet_steps that were not implemented
vantreeseba Feb 11, 2014
a038071
fixing some issues with cli step / json formatter feature on windows
vantreeseba Feb 11, 2014
04b984d
updating version of connect in package.json to 2.13.0
vantreeseba Feb 17, 2014
66b9f7d
adding error message when a user tries to use examples outside of a s…
vantreeseba Feb 17, 2014
e7e2198
added dependency to underscore.string, changed snippet builder to cam…
vantreeseba Feb 18, 2014
4f76479
removing duplicated step insertion
vantreeseba Feb 24, 2014
aeb2630
fixing spec for assembler
vantreeseba Feb 24, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions features/scenario_outlines.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
Feature: Scenario Outlines and Examples

Scenario: Basic outline
Given the following feature:
"""
Feature: testing scenarios
Background:
Given a background step

Scenario Outline: outline
When a <some> step
Then i get <result>
Examples:
| some | result |
| passing | passed |
| failing | skipped |
"""
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 |
"""
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:
"""
[["first","second"],["1","2"]]
"""

Scenario: Outline with doc string
Given the following feature:
"""
Feature: testing scenarios
Scenario Outline: outline
When a doc string step:
\"\"\"
I am doc string in <example> example
And there are <string> string
\"\"\"
Examples:
| example | string |
| first | some |
"""
And the step "a doc string 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
"""

Scenario Outline: outline
When a <some> step
Then i get <result>
Examples:
| some | result |
| passing | passed |
| failing | skipped |
8 changes: 8 additions & 0 deletions features/step_definition_snippets.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ Feature: step definition snippets
"""
When Cucumber executes the scenario
Then a "Given" step definition snippet for /^I have some "([^"]*)", "([^"]*)" and "([^"]*)" cucumbers$/ with 3 parameters is suggested

Scenario: outline steps with examples
Given a scenario with:
"""
Given I have <some> cucumbers
"""
When Cucumber executes the scenario
Then a "Given" example step definition snippet for /^I have "(.*)" cucumbers$/ with 1 parameters is suggested
4 changes: 2 additions & 2 deletions features/step_definitions/cli_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ var cliSteps = function cliSteps() {
var actualError = lastRun['error'];
var actualStderr = lastRun['stderr'];

expectedOutput = expectedOutput.replace(/<current-directory>/g, tmpDir);
expectedOutput = expectedOutput.replace(/<current-directory>/g, tmpDir.replace(/\\/g,'/'));

try { var actualJson = JSON.parse(actualOutput); }
try { var actualJson = JSON.parse(actualOutput.replace(/\\\\/g,'/')); }
catch(err) { throw new Error("Error parsing actual JSON:\n" + actualOutput); }

try { var expectedJson = JSON.parse(expectedOutput); }
Expand Down
114 changes: 15 additions & 99 deletions features/step_definitions/cucumber_steps.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var cucumberSteps = function() {
var Given = When = Then = this.defineStep;
var Given = When = Then = this.defineStep;
var World = require('./cucumber_world').World;
this.World = World;

Expand All @@ -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 @@ -96,6 +84,14 @@ setTimeout(callback.pending, 10);\
callback();
});

Given(/^the step "([^"]*)" has a passing mapping that receives a doc string$/, function(stepName, callback) {
this.stepDefinitions += "Given(/^" + stepName + "$/, function(docString, callback) {\
world.docString = docString;\
callback();\
});";
callback();
});

Given(/^the following data table in a step:$/, function(dataTable, callback) {
this.featureSource += "Feature:\n";
this.featureSource += " Scenario:\n";
Expand All @@ -111,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 @@ -149,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 @@ -165,13 +132,9 @@ 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);
//callback.pending();
});

When(/^Cucumber runs the features$/, function(callback) {
Expand Down Expand Up @@ -200,38 +163,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 @@ -309,6 +240,11 @@ callback();\
callback();
});

Then(/^the received doc string equals the following:$/, function(docString, callback) {
this.assertEqual(docString, World.mostRecentInstance.docString);
callback();
});

this.Then(/^the explicit World object function should have been called$/, function(callback) {
this.assertTrue(this.explicitWorldFunctionCalled);
callback();
Expand Down Expand Up @@ -341,25 +277,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;
2 changes: 1 addition & 1 deletion features/step_definitions/cucumber_world.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ proto.assertScenarioNotReportedAsFailing = function assertScenarioNotReportedAsF
};

proto.assertPassedStep = function assertPassedStep(stepName) {
if (!this.isStepTouched(stepName))
if (!this.isStepTouched(stepName))
throw(new Error("Expected step \"" + stepName + "\" to have passed."));
};

Expand Down
27 changes: 27 additions & 0 deletions features/step_definitions/scenario_execution_steps.js
Original file line number Diff line number Diff line change
@@ -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;
17 changes: 17 additions & 0 deletions features/step_definitions/scenario_outline_steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var scenario_outline_steps = function() {
var Given = When = Then = this.defineStep;
var World = require('./cucumber_world').World;
this.World = World;

this.When(/^a (.*) step$/, function (some, callback) {
this.assertTrue(some === "passing" || some === "failing");
callback();
});

this.Then(/^i get (.*)$/, function (result, callback) {
this.assertTrue(result === "passed" || result === "skipped");
callback();
});
}

module.exports = scenario_outline_steps;
14 changes: 14 additions & 0 deletions features/step_definitions/step_definition_snippets_steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var stepDefinitionSnippetsSteps = function() {
var Given = When = Then = this.defineStep;
var World = require('./cucumber_world').World;
this.World = World;

this.Then(/^a "([^"]*)" example step definition snippet for \/\^I have "([^"]*)" cucumbers\$\/ with (\d+) parameters is suggested$/, function (stepName, snippetParameter, paramCount, callback) {
this.assertEqual(stepName, "Given");
this.assertEqual(snippetParameter,'(.*)');
this.assertEqual(paramCount,"1");
callback();
});
}

module.exports = stepDefinitionSnippetsSteps;
Loading