Skip to content

Commit

Permalink
Fixed first/last flag on FeatureFileVisitor
Browse files Browse the repository at this point in the history
Fixed find feature files regex pattern fdr windows in example project
  • Loading branch information
jonsamwell committed Sep 15, 2021
1 parent 239a4ca commit 2c6fa8a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [2.0.5+1] - 15/09/2021

* Fixed first/last flag on `FeatureFileVisitor`
* Fixed find feature files regex pattern fdr windows in example project

## [2.0.5] - 15/09/2021

* Added json reporter test case for multi-scenario
Expand Down
2 changes: 1 addition & 1 deletion example/report.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion example/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import 'supporting_files/worlds/custom_world.world.dart';
String buildFeaturesPathRegex() {
// '\' must be escaped, '/' must not be escaped:
var featuresPath = (Platform.isWindows)
? 'features\${Platform.pathSeparator}.*\.feature'
? 'features${Platform.pathSeparator}\\.*\.feature'
: 'features${Platform.pathSeparator}.*\.feature';

return featuresPath;
}

Expand Down
16 changes: 10 additions & 6 deletions lib/src/gherkin/ast/feature_file_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,25 @@ class FeatureFileVisitor {
_tagsToList(feature.tags),
);

for (final scenario in feature.scenarios) {
for (var i = 0; i < feature.scenarios.length; i += 1) {
final scenario = feature.scenarios.elementAt(i);
final isFirst = i == 0;
final isLast = i == (feature.scenarios.length - 1);
final allScenarios = scenario is ScenarioOutlineRunnable
? scenario.expandOutlinesIntoScenarios()
: [scenario];
var acknowledgedScenarioPosition = false;

for (var i = 0; i < allScenarios.length; i += 1) {
final childScenario = allScenarios.elementAt(i);

for (var childScenario in allScenarios) {
await visitScenario(
childScenario.name,
_tagsToList(childScenario.tags),
i == 0,
i == (allScenarios.length - 1),
acknowledgedScenarioPosition ? false : isFirst,
acknowledgedScenarioPosition ? false : isLast,
);

acknowledgedScenarioPosition = true;

if (feature.background != null) {
final bg = feature.background;

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: gherkin
version: 2.0.5
version: 2.0.5+1
description: A Gherkin parsers and runner for Dart which is very similar to Cucumber, it provides the base BDD functionality ready for use in platform specific implementations i.e. flutter/web
homepage: https://github.com/jonsamwell/dart_gherkin

Expand Down

0 comments on commit 2c6fa8a

Please sign in to comment.