getting-started
Getting Started
Project layout
A Behave project keeps spec files in a specs/ directory at the project root. The behave runner picks up any file matching spec.raku (e.g. 001-basic-spec.raku, users-spec.raku, subdir/admin-spec.raku).
my-project/
āāā lib/
ā āāā MyApp.rakumod
āāā specs/
āāā basic-spec.raku
āāā users/
āāā auth-spec.rakuYour first spec
Every spec file starts with use BDD::Behave; and then declares one or more top-level describe blocks.
use BDD::Behave;
describe 'arithmetic', {
it 'adds integers', {
expect(1 + 1).to.be(2);
}
it 'multiplies integers', {
expect(3 * 4).to.be(12);
}
}Running specs
Run all specs found in specs/:
behaveRun a single spec file:
behave specs/basic-spec.rakuDuring local development of an app whose lib/ is not yet installed, prefix with raku -Ilib:
raku -Ilib bin/behave specs/basic-spec.rakuSee Running Specs for the full set of options.
Where to go next
describe / context: group related examples
it: define an example
let: lazy, memoized values per example
Hooks:
before-each,after-each,before-all,after-allShared Contexts: reusable
lets and hooks viashared-context/include-contextexpect: assertions