Module: Janus::TestHelper

Defined in:
lib/janus/test_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



3
4
5
6
7
# File 'lib/janus/test_helper.rb', line 3

def self.included(klass)
  klass.class_eval do
    setup { @janus = Janus::Manager.new(request, cookies) }
  end
end

Instance Method Details

#assert_authenticated(scope) ⇒ Object



21
22
23
# File 'lib/janus/test_helper.rb', line 21

def assert_authenticated(scope)
  assert @janus.authenticated?(scope), "Expected #{scope} to be authenticated."
end

#assert_not_authenticated(scope) ⇒ Object



25
26
27
# File 'lib/janus/test_helper.rb', line 25

def assert_not_authenticated(scope)
  assert !@janus.authenticated?(scope), "Expected #{scope} to not be authenticated."
end

#sign_in(user, options = {}) ⇒ Object



9
10
11
# File 'lib/janus/test_helper.rb', line 9

def (user, options = {})
  @janus.(user, options)
end

#sign_out(user_or_scope = nil) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/janus/test_helper.rb', line 13

def sign_out(user_or_scope = nil)
  if user_or_scope
    @janus.logout(Janus.scope_for(user_or_scope))
  else
    @janus.logout
  end
end