Skip to main content

Crate expectation_language

Crate expectation_language 

Source
Expand description

The .expect file format: a Gherkin-flavoured language for a suite’s vocabulary, expectations and user stories.

Suite: Kettle

Vocabulary:
  State: the kettle is off | heating | dry
  State: the dial is 0..100 %
  Event: the user presses reset

Background:
  Given the kettle is off

Feature: Heating
  Expectation: Turning the dial up starts the kettle
    Given the kettle is off
    When the dial is above 55 %
    Then the kettle is heating

Story: First cup
  As a tea drinker
  I want to start the kettle by turning the dial

  Scenario: Turn it on
    When the dial is 80 %
    Then the kettle is heating

load_dir reads every *.expect file under a directory into one suite; load_sources does the same from strings.

Modules§

step
Step text to meaning. A step is either an event (“the user presses reset”) or a fact about a state: <subject> is [not] <predicate>, where the predicate is one or more of the state’s values (“off or heating”) or, for numbers, a comparison (“above 55 %”, “at most 10”, “between 20 and 40 %”, “0 %”). A Then can also be relative: <subject> goes up by <n>, goes down by <n> or stays the same.

Structs§

Loaded
A suite and everything wrong with it. Check Loaded::has_errors before using the suite: steps that didn’t resolve are left out of it.

Constants§

EXTENSION

Functions§

load_dir
Every *.expect file under dir (recursively, in path order) as one suite, named by its Suite: line or else after the directory. File names in diagnostics are relative to dir.
load_dir_for
As load_dir, read for platform.
load_sources
Parse named sources, in order, as one suite (for its default platform).
load_sources_for
As load_sources, read for platform (see lens): its variants replace the plain lines and what is On: elsewhere is left out. None is the default platform.