NAME

Dredd::Hooks - Handler for running Hook files for Dredd

SYNOPSIS

use Dredd::Hooks;

my $hook_runner = Dredd::Hooks->new(hook_files => [...]);

my $hook_runner->$event."_hook"

DESCRIPTION

Dredd::Hooks provides the code to actually run the hooks used in the Dredd API testing suite.

Unless you are righting your own TCP server to accept Dredd Hook requests then you likely want Dredd::Hooks::Methods which describes how to write Dredd Hook files.

ATTRIBUTES

hook_files

An arrayref of fully expanded file names that will be required and should contain hook code.

See Dredd::Hooks::Methods for information on creating these files

EVENT METHODS

beforeEach_hook (transaction HashRef -> transaction HashRef)

Runs hooks for the BeforeEach event from Dredd. This then calls the before_hook before returning. This is because the before event is not an event directly called by dredd.

before_hook (transaction HashRef -> transaction HashRef)

Runs the before event hooks and returns the modified transaction object

NOTE: This is currently run by the beforeEach handler as the before event is not an event directly sent from Dredd.

beforeEachValidation_hook (transaction HashRef -> transaction HashRef)

Handles the beforeEachValidation event from Dredd. This then calls the beforeValidation_hook to handle the beforeValidation event.

beforeValidation_hook (transaction HashRef -> transaction HashRef)

Handles the beforeValidation event and returns the modified transaction.

NOTE: This event is called from beforeEachValidation_hook as it is not and event directly run from Dredd.

afterEach_hook (transaction HashRef -> transaction HashRef)

Handles the afterEach event from Dredd. Runs the after_hook handler first before running hooks for this event.

after_hook (transaction HashRef -> transaction HashRef)

Handles the after event and returns the modified transaction.

NOTE: This event is called from the afterEach_hook as it is not and event directly run from Dredd.

beforeAll (transactions ArrayRef[transaction] -> transactions ArrayRef[transaction])

Handles the beforeAll event from Dredd. Receives an arrayref of transaction hashrefs and returns the modified version.

afterAll (transactions ArrayRef[transaction] -> transactions ArrayRef[transaction])

Handles the afterAll event from Dredd. Receives an arrayref of transaction hashrefs and returns the modified version.

BUGS AND REQUESTS

This modules source is stored in GitHub and any issues or suggestions should be posted there.

LICENSE

Copyright (C) Mike Eve.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Mike Eve <ungrim97@gmail.com>