The mapping layer
The mapping layer is the set of resources that map the scenarios to the implementation code that executes them. The resources in this layer are sometimes referred to as glue code. (Glue code is an programming term code that exists to connect different sets of code that are otherwise incompatible.)
The fundamental building blocks of this layer are the step methods, Context Factory, and the RemoteSmokeTestHelperModule class.
A step method is a Gosu method that maps a scenario step to its implementation. Step methods are grouped together in step files.
Context Factory is the name used to refer to two Gosu classes: ContextFactory (an interface) and ContextFactoryImpl (an implementation of the interface). All of the implementations needed for testing (such as implementations for admin testing, activity testing, and so on) are injected into Context Factory. Context Factory is injected into every step file. In this way, Context Factory acts as a dependency object that provides every step definition with the ability to identify and call the appropriate implementation.
By itself, Context Factory does not have any information on which impl class to go to find the implementation for a particular method. The logic that identifies this is primarily stored in the RemoteSmokeTestHelperModule. This class consists of a set of custom bindings that bind every interface to the appropriate impl. For example, RemoteSmokeTestHelperModule binds the AdminContext interface to AdminContextImpl. Whenever a step method needs to access a method in a specific impl, it requests an instance of the interface and then accesses the method through the binding between the interface and the impl.
The following diagram depicts an example of resources in the mapping layer. Specifically, this example is the AdminSteps file, which provides the step method for the Given I am a user with the "X" role scenario step. The step file injects Context Factory, which provides access to the class that declares the implementation code.

For more information on writing step methods, see Creating step methods. For more information on Context Factory, see Extending context APIs.
