cucumber-rs / cucumber

Cucumber testing framework for Rust. Fully native, no external test runners or dependencies.
https://cucumber-rs.github.io/cucumber/main
Apache License 2.0
563 stars 69 forks source link

Docstrings are dedented to first line, not to opening """ #339

Closed aisrael closed 2 months ago

aisrael commented 2 months ago

Summary

According to the documentation:

NOTE: Indentation of the opening """ is unimportant, although the common practice is to indent them. The indentation inside the triple quotes, however, is significant. Each line of the doc string will be dedented according to the opening """. Indentation beyond the column of the opening """ will therefore be preserved.

However, in testing, when writing steps with docstrings, lines inside the triple backticks (```) or triple quotes (""") are dedented according to the first line.

Examples

The following two steps result in identical docstrings:

And the output should contain:
  """
  "id": 42,
  "foo": "bar",
  """

And

And the output should contain:
  """
    "id": 42,
    "foo": "bar",
  """

However, the following results in the second line being indented by two spaces:

And the output should contain:
  """
    "id": 42,
      "foo": "bar",
  """

I can provide a minimum reproducible example (MRE) if requested.

aisrael commented 2 months ago

(I just realized this issue probably better belongs in https://github.com/cucumber-rs/gherkin.)

aisrael commented 2 months ago

Opened https://github.com/cucumber-rs/gherkin/issues/43 instead, closing this.