Module: Aker::Test::Helpers

Defined in:
lib/aker/test/helpers.rb

Overview

Contains helpers for writing tests on aker-protected code.

Instance Method Summary collapse

Instance Method Details

#login_env(user) ⇒ Hash<String, Aker::Rack::Facade>

Generates an environment hash that marks user as logged in. You can use the generated hash in pre-existing requests, merge the hash with the environment generated by Rack::MockRequest.env_for, etc.

Parameters:

  • user (String, Aker::User)

    a user's username or a User object. Your Aker configuration must use an authority that implements find_user for username lookup to work.

Returns:

  • (Hash<String, Aker::Rack::Facade>)

    a Hash of the form {'aker' => (a Aker::Rack::Facade)}


17
18
19
20
21
# File 'lib/aker/test/helpers.rb', line 17

def (user)
  u = Aker::User === user ? user : Aker.authority.find_user(user)

  { 'aker.check' => Aker::Rack::Facade.new(Aker.configuration, u) }
end