-
Notifications
You must be signed in to change notification settings - Fork 94
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
Add Rule keyword support #246
Conversation
I really want this feature, looking forward to reviewing it |
5b2499a
to
2ee0f1e
Compare
2ee0f1e
to
f77b8d9
Compare
This one still doesn't work: It turns out Feature: Complex background
...
Rule: My Rule
Scenario: with examples
Given the <value> minimalism
Examples:
| value |
| 1 |
| 2 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really good that you've used the cucumber tests to guide things - your comment about the Scenario Outline difference is captured in #153
I've left a few comments, the ones marked [BC] would allow us to do this as a minor release, I'm not sure if that's the right approach or not yet
* | ||
* @return string | ||
*/ | ||
public function getRuleKeywords(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[BC] We should define a new interface that extends KeywordsInterface and adds this method
@@ -72,6 +77,7 @@ public function __construct( | |||
$description, | |||
array $tags, | |||
BackgroundNode $background = null, | |||
array $rules, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[BC] we should add this as the last parameter and make it optional (with a default)
@@ -72,6 +77,7 @@ public function __construct( | |||
$description, | |||
array $tags, | |||
BackgroundNode $background = null, | |||
array $rules, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a slight concern that we lose the ordering of scenarios+rules here by having them as separate arguments. (The main concern is the impact on Behat's formatters).
Perhaps we should be passing an array of Scenarios+Rules? Needs some thought
/** | ||
* @return RuleNode[] | ||
*/ | ||
public function getRules(): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[BC] We need to consider how a consumer will know this method is available. Maybe we need an interface to hint it? I slightly prefer
if ($featureNode instanceof FeatureRulesNode) {
vs
if(method_exists($featureNode, 'getRules')){
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, if a consumer does not want to have to check for existence, the easiest way is to bump their min version of behat/gherkin.
To me, there is no need for an interface (which would not be allowed to be removed without a BC break, and there is no right way to trigger deprecations for instanceof checks relying on deprecated interfaces, only static analysis can do it)
@@ -100,6 +100,7 @@ public function translationTestDataProvider() | |||
, | |||
array(), | |||
$background, | |||
[], // TODO: rules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this should be resolved before merge
@pamil @stof we need to consider how Behat will adapt to this change. It'll impact tagging, running and a lot more.
|
I found inconsistency with https://github.com/cucumber/common: Feature: Some rules
Background:
Given fb
Rule: A
The rule A description
Background:
Given ab
Example: Example A
Given a That parser doesn't remove indentation of description: "description":" The rule A description" We can keep indentation data in |
#245 is just better way for this. |
Hi,
PR provides the
Rule
keyword support (https://cucumber.io/docs/gherkin/reference/#rule).