Lexer for BDD features and stories

Issue #961 new
Crazy Penguin
created an issue

Pygments is a great tool and it is being used in many places, including bitbucket, github and GitLab.

As such, it would be nice to have support for BDD features/stories for Issues, Merge/Pull requests, etc.

I'm attaching a simple patch file that contains a possible example of such lexer (this is my first attempt to write a lexer, so please bare with me here!).

A sample BDD story file can look something like this:

View Quotes should do something
Meta:
@verifies G989

Scenario: Should kick user
Scenario: Kick user
Scenario:Kick user with no space
Scenario:Kick user with no space Given
Meta:
@verifies R1231

Given a user is logged in
When he posts something illegal
Then he should be kicked off site
And black-listed

Should kick user

Given a user logs out
On main page
It should kick him

Feature: Serve coffee
    Coffee should not be served until paid for
    Coffee should not be served until the button has been pressed
    If there is no coffee left then money should be refunded

  Background:
    Given a global administrator named "Greg"
    And a blog named "Greg's anti-tax rants"
    And a customer named "Dr. Bill"
    And a blog named "Expensive Therapy" owned by "Dr. Bill"

  Scenario: Buy last coffee
    Given there are 1 coffees left in the machine
    And I have deposited 1$
    When I press the coffee button
    Then I should be served a coffee

  Scenario Outline: eating
    Given there are <start> cucumbers
    When I eat <eat> cucumbers
    Then I should have <left> cucumbers

    Examples:
      | start | eat | left |
      |  12   |  5  |  7   |
      |  20   |  5  |  15  |

  Scenario Outline: eating
    Given there are $start cucumbers
    When I eat $eat cucumbers
    Then I should have $left cucumbers

    Examples:
      | start | eat | left |
      |  12   |  5  |  7   |
      |  20   |  5  |  15  |

Comments (2)

  1. Log in to comment