Hi Vladimir. Requirements as code and the Specification pattern serve different purposes.
The Specification pattern, as described by Martin Fowler and Eric Evans, can be used to filter a set of objects based on criteria defined in a separate Specification object, or in general to test if an object matches certain criteria. Quote: This theme is the notion of some test that we can apply to candidate objects to see if they fit our needs, this test is a specification of what is needed. The specification is, in essence, a boolean function which applies to the candidate which indicates whether or not it matches.
Requirements as code, in contrast, is about conditional, state based behavior. Under which circumstances should the system perform which method? That executed behavior isn’t part of the Specification pattern. So requirements as code goes beyond the pattern.
You can combine the two if you want to. Use a Specification object in the .condition part at the start of a flow:
.flow("Assign limit twice").condition(limitAlreadyAssigned)
limitAlreadyAssignedcould be a Specification object. Hope that clears things up.