explanation/markup-is-yours says the matcher sees exactly what is written, and reference/examples says a paragraph becomes an example when "at least one sentence matches a step". Neither says how a sentence matches a step.
The mechanic is in matcher.js: the compiled Cucumber Expression has its ^/$ anchors stripped and is scanned for as a substring, and every non-overlapping match in the sentence becomes a step.
I only learned this by reading the source, and once I had, four separate behaviours I'd been treating as quirks turned out to be one rule:
Related, and also undocumented as far as I can find: stripLeadingKeyword / keywords-data.js mean 586 Gherkin keywords in many languages are stripped from the front of a sentence. A, An, I, In, No, Do, E, Se and Ma are all in that list. It didn't bite me, but "a sentence beginning with the word No has that word removed before matching" is surprising enough to write down.
Suggestion
A short section in reference/examples — "How a sentence matches" — stating that matching is substring-based, case-sensitive, that multiple non-overlapping steps in one sentence all run in order, and that leading keywords are stripped. Three paragraphs would have saved me a source-reading session and most of #118.
The multi-step-per-sentence point in particular reads like a feature you'd want people to know about: it is the difference between an oath that reads like documentation and one that reads like a list of steps with the keywords filed off.
explanation/markup-is-yourssays the matcher sees exactly what is written, andreference/examplessays a paragraph becomes an example when "at least one sentence matches a step". Neither says how a sentence matches a step.The mechanic is in
matcher.js: the compiled Cucumber Expression has its^/$anchors stripped and is scanned for as a substring, and every non-overlapping match in the sentence becomes a step.I only learned this by reading the source, and once I had, four separate behaviours I'd been treating as quirks turned out to be one rule:
Ben checks out the basket, "ben@example.com" completes the payment, and the process order workflow is done.is three steps in one sentence. This is, to me, the best thing about writing Varar oaths — and I found it by accident. It deserves to be a headline, not an inference.Unable to choose between them, the visitor puts these shares in the basket:matches; the leading clause is just text the matcher skips past.Related, and also undocumented as far as I can find:
stripLeadingKeyword/keywords-data.jsmean 586 Gherkin keywords in many languages are stripped from the front of a sentence.A,An,I,In,No,Do,E,SeandMaare all in that list. It didn't bite me, but "a sentence beginning with the word No has that word removed before matching" is surprising enough to write down.Suggestion
A short section in
reference/examples— "How a sentence matches" — stating that matching is substring-based, case-sensitive, that multiple non-overlapping steps in one sentence all run in order, and that leading keywords are stripped. Three paragraphs would have saved me a source-reading session and most of #118.The multi-step-per-sentence point in particular reads like a feature you'd want people to know about: it is the difference between an oath that reads like documentation and one that reads like a list of steps with the keywords filed off.