Skip to content

Latest commit

 

History

History
128 lines (97 loc) · 10.4 KB

the_beaker_dsl.md

File metadata and controls

128 lines (97 loc) · 10.4 KB

The Beaker DSL

The Beaker Domain-Specific Language (DSL) is a set of Ruby convenience methods provided by Beaker to make testing easier.

Beaker maintains yard documentation covering the DSL to help you use it. That documentation can sometimes be difficult to navigate, however, so this doc has been created to help you find your way around.

DSL Caveats

Note that if you're using a beaker-library, any methods provided there won't be documented here. You can refer to the beaker-libraries listing doc for links to those projects which should include their own documentation.

Another common point of confusion about the Beaker DSL is that there is a similar set of methods that come along in Host objects themselves. You can tell these methods apart in a test by their invocation method. Host methods are Ruby instance methods on Host objects, so they'll be invoked on a Host object like so:

host.host_method_name(host_method_params)

and they'll know by default which hosts to act on because you've provided them that through choosing which hosts to call them on. Beaker DSL methods are called in the wider context of the test itself, however, and often need to be passed the hosts you'd like them to act on:

on(hosts, "cowsay 'the tortoise lives in agony'")

Another way you can tell them apart is their location in the codebase, & thus in the Rubydocs. Beaker DSL methods live under the Beaker::DSL module, whereas Host methods are all included in the Beaker::Host object itself. Follow that link to the Host Rubydoc and checkout the Instance Method Summary to see a listing of Host methods. Note that they won't be listed here though.

Assertions

To be used for confirming the result of a test is as expected. Beaker include all Minitest assertions, plus some custom built assertions.

Helpers

DSL methods designed to help you interact with hosts (like running arbitrary commands on them) or interacting with the web (checking is a given URL is alive or not).

Host

DSL methods for host manipulation.

Web

Helpers for web actions.

Test

DSL methods for setting information about the current test.

Outcomes

Methods that indicate how the given test completed (fail, pass, skip or pending).

Patterns

Shared methods used as building blocks of other DSL methods.

Roles

DSL methods for accessing hosts of various roles.

Structure

DSL methods that describe and define how a test is executed.