Skip to content

Docs: the substring matching rule is the key mechanic and is not written down #119

Description

@aslakhellesoy

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions