cucumber / gherkin

A parser and compiler for the Gherkin language.
MIT License
188 stars 62 forks source link

Nested rule doesn't consume all needed backgrounds #126

Open elchupanebrej opened 1 year ago

elchupanebrej commented 1 year ago

👓 What did you see?

feature = """
Feature: Nested rules
  Background:
    Given Feature background

  Rule: Outer rule
    Background:
      Given Outer rule background step

    Rule: Nested rule
      Background:
        Given Nested background rule step

      Example:
        Then Scenario step
"""

from gherkin.parser import Parser
from gherkin.pickles.compiler import Compiler
parser = Parser()
gherkin_document = parser.parse(feature)
gherkin_document["uri"] = 'local'
pickles = Compiler().compile(gherkin_document)

I get next pickle:

[{'astNodeIds': ['8'],
  'id': '3',
  'language': 'en',
  'name': '',
  'steps': [{'astNodeIds': ['0'],
             'id': '0',
             'text': 'Feature background',
             'type': 'Context'},
            {'astNodeIds': ['5'],
             'id': '1',
             'text': 'Nested background rule step',
             'type': 'Context'},
            {'astNodeIds': ['7'],
             'id': '2',
             'text': 'Scenario step',
             'type': 'Outcome'}],
  'tags': [],
  'uri': 'local'}]

so Outer rule background step is missing in the pickle

✅ What did you expect to see?

All 4 steps from every level background is present in the pickle

📦 Which tool/library version are you using?

Python 3.10.9 gherkin-official 24.1.0

This text was originally generated from a template, then edited by hand. You can modify the template here.

luke-hill commented 1 year ago

I'm 95% certain we test this in our acceptance tests. However you are using quite an old version (So it maybe something we've only introduced recently).

I do know python is one of the versions that has slightly less usage, that might be why.

mpkorstanje commented 1 year ago

A quick guess would be that we fixed this somewhere after the mono repo split. We haven't released the python module since. https://github.com/cucumber/gherkin/issues/148.

elchupanebrej commented 2 months ago

gherkin-official 29.0 - Reproduced