Fork me on GitHub

Extending easyb

easyb can be extended in four ways.

Table 1. table
Extension Mechanism Description Behavior

io.easyb.plufgin.EasybPlugin

Provides hooks into the behavior lifecycle processing.

Specifications and Stories

io.easyb.plugin.ExampleDataParser

Provides new ways of injecting data into your where AND example clauses.

Stories

io.easyb.plugin.SyntaxExtension

Specifications and Stories

Both extension points are based on the Java Service Provider Interface.

Plugins

Extension Points

Sources of Data

The way that data is processed in the where clause depends on plugins and two plugins are added by default to the end of the list of plugins defined for dealing with where data. These deal with a map or a closure - both examples are shown above. The syntax for these plugins will be changing to deal with Gherkin. The current interface that needs to be implemented is:

Groovy Example
public interface ExampleDataParser {
    /**
     * processData if the data is of a type that this plugin should parse, then
     * it needs to decode it, calling the closure for each iteration with a map
     * containing fields and values to add to the binding. The parser can add new elements
     * to the binding for the duration of its operation, but must remove them (for consistency)
     * on completion. The StoryProcessing will take care of removing the excess properties
     * in the binding that occur because of these plugins.
     *
     * @param data - the data object passed in the Story
     * @param closure - a closure that we can iterate over for each record. It expects one parameter { map -> }
     * @param binding - the current binding
     *
     * @return true if we processed it, false if not
     */
     boolean processData(data, closure, binding);
}

Syntax Extensions