Skip to content

Add helpers for running before and after callbacks #91

Open

Description

@jcredding

We should add helpers for running a before and after callback.

These are special callbacks that we typically don't run in test suites. This gives the user the ability to put authorization checking into a before callback for all of its handlers but not have to worry about stubbing it out for every test.

It would be nice though if we had a way to run these via the runner to test them. Currently, the user has to do something like:

@handler_class.before_callbacks.each do |callback|
  @handler.instance_eval(&callback)
end

This requires knowing to much about runners and handlers. We should either add an option when creating a test runner to run the callbacks:

@runner = test_runner(@handler_class, :run_before_callbacks => true)

or we should add a method to the runner that can be called (maybe both?):

@runner.run_before_callbacks

The benefit of the first option is that we can run the callbacks when they normally would be run, before init! is called. The "problem" with it is you can no longer write that attribute to the handler if for some reason a handler had a run_before_callbacks writer.

Related to: redding/deas#180

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions