transient class to hold an example description before creating a full Example
This class creates Given or Then extractors from a regular expression and a function
at any point in time a regex sequence can be transformed as a sequence of Fragments
implicit conversion to transform a Given[Y] to Given[X] when Y <: X
This implicit allows to use the "so" object:
This implicit allows to use the "so" object:
"given the name: ${eric}, then the age is ${18}" ! so { case (name: String, age: String) => age.toInt must_== 18 }
factory method to create a Given or a Then element from a regex, using a regex denoting groups to extract
factory method to create a Given or a Then element from a regex, using a regex denoting groups to extract
factory method to create a Given or a Then element from a regex
factory method to create a Given or a Then element from a regex
implicit conversion to transform a Then[Y] to Then[X] when Y <: X
implicit conversion to transform a When[P, Q] to When[R, S] when R <: P and S >: Q
This trait provides building blocks to create steps and examples from regular expression.
It is used to implement a Given-When-Then way of describing systems.
Fragments are created by adding a
Given
step to aText
:"name: ${user}" ^ givenName
This creates a PreStep object containing the current context (representing all the extracted values) and a list of Fragments containing:
Text("name: ${user}")
${}
Then, this PreStep object can be followed by another piece of Text to create a PreStepText object. This object merely stores the additional Text fragment so that values can be extracted from it when a
When
step is added:Eventually, when a
Then
step is added, a sequence of PostStep/PostStepText objects is created. Those objects use the current context and the results returned by theThen
objects to create Examples.The last PostStep object contains the list of all fragments created by the Given/When/Then sequence: