Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Gherkin: Remove Background from Rule in grammar #590
Based on conversation at Cukenfest, we will take out Background from Rules and see if valid use cases emerge
This will become a parse error:
Currently backgrounds are inlined into the pickles created from the Scenarios
I had a crack at this (removed
Because of the way Berp works, a rule with a background does not cause a parser error. It just generates a
The Berp parser will only attempt to match lines it expects. Everything else becomes a description. I think parser is unable to detect quite a lot of parse errors. /cc @gasparnagy
@aslakhellesoy I see. It was definitely by design like that, but we can question whether this was really a good choice (I am not sure anymore.) I think besides "Background" and maybe "Feature" all the other keywords can be used pretty much everywhere, so the impact of this behavior is not that high.
If you write "Background" after a "Rule" and start with the first "Given" step, it will anyway cause a synxtax error (if we don't allow backgrounds for rules), because at that point only "Scenario" or another "Rule" can come, so there will be no hidden error caused by that.
I would go ahead removing the Background for the Rule and maybe have another separate discussion about how the parser should treat the "other" token. We can easily change BERP (if we want) to check every other token and only accept "Other" if no other token is matching. This will not require any change in the language implementations.