Skip to content

Commit 3072661

Browse files
committed
Don't skip scenario outlines (close #245)
1 parent c38d63a commit 3072661

File tree

4 files changed

+50
-25
lines changed

4 files changed

+50
-25
lines changed

features/scenario_outlines.feature

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Feature: Scenario Outlines and Examples
77
Background:
88
Given a background step
99
10-
Scenario Outline: outline
10+
Scenario Outline: basic outline
1111
When a <some> step
1212
Then i get <result>
1313
Examples:
@@ -21,7 +21,7 @@ Feature: Scenario Outlines and Examples
2121
And the step "i get passed" has a passing mapping
2222
And the step "i get skipped" has a passing mapping
2323
When Cucumber runs the feature
24-
Then the scenario called "outline" is reported as failing
24+
Then the scenario called "basic outline" is reported as failing
2525
And the step "a background step" passes
2626
And the step "a passing step" passes
2727
And the step "a failing step" passes
@@ -30,9 +30,9 @@ Feature: Scenario Outlines and Examples
3030

3131
Scenario: Outline with table
3232
Given the following feature:
33-
"""
33+
"""
3434
Feature: testing scenarios
35-
Scenario Outline: outline
35+
Scenario Outline: outline with table
3636
When a table step:
3737
| first | second |
3838
| <first> | <second> |
@@ -49,9 +49,9 @@ Feature: Scenario Outlines and Examples
4949

5050
Scenario: Outline with doc string
5151
Given the following feature:
52-
"""
52+
"""
5353
Feature: testing scenarios
54-
Scenario Outline: outline
54+
Scenario Outline: outline with doc string
5555
When a doc string step:
5656
\"\"\"
5757
I am doc string in <example> example
@@ -64,15 +64,37 @@ Feature: Scenario Outlines and Examples
6464
And the step "a doc string step:" has a passing mapping that receives a doc string
6565
When Cucumber runs the feature
6666
Then the received doc string equals the following:
67-
"""
68-
I am doc string in first example
69-
And there are some string
70-
"""
71-
72-
Scenario Outline: outline
73-
When a <some> step
74-
Then i get <result>
75-
Examples:
76-
| some | result |
77-
| passing | passed |
78-
| failing | skipped |
67+
"""
68+
I am doc string in first example
69+
And there are some string
70+
"""
71+
72+
Scenario: Several outlines
73+
Given the following feature:
74+
"""
75+
Feature: testing scenarios
76+
Scenario Outline: scenario outline 1
77+
When step <id>
78+
79+
Examples:
80+
| id |
81+
| a |
82+
| b |
83+
84+
Scenario Outline: scenario outline 2
85+
When step <id>
86+
87+
Examples:
88+
| id |
89+
| c |
90+
| d |
91+
"""
92+
And the step "step a" has a passing mapping
93+
And the step "step b" has a passing mapping
94+
And the step "step c" has a passing mapping
95+
And the step "step d" has a passing mapping
96+
When Cucumber runs the feature
97+
Then the step "step a" passes
98+
And the step "step b" passes
99+
And the step "step c" passes
100+
And the step "step d" passes

lib/cucumber/ast/feature.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var Feature = function(keyword, name, description, uri, line) {
4141
addFeatureElement: function addFeatureElement(featureElement) {
4242
var background = self.getBackground();
4343
featureElement.setBackground(background);
44-
featureElements.add(featureElement);
44+
featureElements.add(featureElement);
4545
},
4646

4747
insertFeatureElement: function insertFeatureElement(index, featureElement) {
@@ -57,7 +57,7 @@ var Feature = function(keyword, name, description, uri, line) {
5757
}
5858
});
5959
},
60-
60+
6161
convertScenarioOutlineToScenarios: function convertScenarioOutlineToScenarios(scenarioOutline) {
6262
var scenarios = scenarioOutline.buildScenarios();
6363
var scenarioOutlineIndex = featureElements.indexOf(scenarioOutline);

lib/cucumber/type/collection.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ var Collection = function () {
3838
},
3939

4040
syncForEach: function syncForEach(userFunction) {
41-
items.forEach(userFunction);
41+
var itemsCopy = items.slice(0);
42+
itemsCopy.forEach(userFunction);
4243
},
4344

4445
forEach: function forEach(userFunction, callback) {

spec/cucumber/type/collection_spec.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,13 @@ describe("Cucumber.Type.Collection", function() {
152152
describe("syncForEach()", function() {
153153
var userFunction = createSpy("userFunction");
154154

155-
it("calls foreach on the array", function() {
156-
spyOn(itemArray, 'forEach');
155+
it("calls foreach on a copy of the array", function() {
156+
var itemsCopy = createSpy("items copy");
157+
spyOn(itemArray, 'slice').andReturn(itemsCopy);
158+
spyOnStub(itemsCopy, 'forEach');
157159
collection.syncForEach(userFunction);
158-
expect(itemArray.forEach).toHaveBeenCalledWith(userFunction);
160+
expect(itemArray.slice).toHaveBeenCalledWith(0);
161+
expect(itemsCopy.forEach).toHaveBeenCalledWith(userFunction);
159162
});
160163
});
161164
});
162-

0 commit comments

Comments
 (0)