Most uses of RoboHydra need writing custom plugins for the behaviour you want. Writing plugins is easy, as you can use ready-made RoboHydra heads that do most common operations. See the tutorial to get an idea of what’s possible and get started, and the head documentation for a detailed description of the capabilities of each type of head.
A plugin is a directory-based Node package (ie. you can’t have
robohydra/plugins/my-plugin.js, it has to be
robohydra/plugins/my-plugin/index.js or similar) that defines the
getBodyParts, and maybe also the function
getSummonerTraits. When loading your plugin, RoboHydra will call
getBodyParts with two parameters:
RoboHydraobject loading the plugin) and
path(the full path to the plugin directory, although it’s also available as
assert, used for assertions (see “The ‘assert’ module” below); and
fixtures, used to load fixtures (see “The ‘fixtures’ module” below).
getBodyParts function must return an object with the following
heads: an array of
scenarios: an object with scenario names as properties, and objects as values.
For more information about how to define heads read the “RoboHydra
heads” section. For more information about the
getSummonerTraits function read the “RoboHydra
summoners” section. For more information about
scenarios read the “Defining Scenarios” section.
Modules are utility functions available to plugins via the second
getBodyParts. This parameter is an object with several
fixtures, …), defined below:
The assert module defines all functions in Node’s
module. However, there
are two key differences between RoboHydra’s assert module and Node’s:
RoboHydra’s assert functions are tied to the RoboHydra server, allowing RoboHydra to fetch and store the results and present them on the web interface.
RoboHydra’s assert functions won’t die when there’s an assert
failure, but instead will return
false. This is much more useful
because it allows you to easily return a normal response to the client
(the same or different than the response the client would get if the
assertion had passed).
These functions are used like
fixtures module defines a single function,
load, to load
fixtures. Fixtures are files inside the
inside a plugin directory. From the plugin code you can call
modules.fixtures.load("foo.bar") to load the file
<plugindir>/fixtures/foo.bar. Note that it returns a
object (not a string!)
or throw an exception if the fixture is not found or not readable.
Back to the documentation index.