Module: Janus::TestHelper
- Defined in:
- lib/janus/test_helper.rb
Instance Attribute Summary collapse
-
#janus ⇒ Object
readonly
Returns the value of attribute janus.
Class Method Summary collapse
Instance Method Summary collapse
- #assert_authenticated(scope) ⇒ Object
- #refute_authenticated(scope) ⇒ Object (also: #assert_not_authenticated)
- #sign_in(user, options = {}) ⇒ Object
- #sign_out(user_or_scope = nil) ⇒ Object
Instance Attribute Details
#janus ⇒ Object (readonly)
Returns the value of attribute janus.
3 4 5 |
# File 'lib/janus/test_helper.rb', line 3 def janus @janus end |
Class Method Details
.included(klass) ⇒ Object
5 6 7 8 9 |
# File 'lib/janus/test_helper.rb', line 5 def self.included(klass) klass.class_eval do setup { @janus = Janus::Manager.new(request, ) } end end |
Instance Method Details
#assert_authenticated(scope) ⇒ Object
23 24 25 |
# File 'lib/janus/test_helper.rb', line 23 def assert_authenticated(scope) assert janus.authenticated?(scope), "Expected #{scope} to be authenticated." end |
#refute_authenticated(scope) ⇒ Object Also known as: assert_not_authenticated
27 28 29 |
# File 'lib/janus/test_helper.rb', line 27 def refute_authenticated(scope) refute janus.authenticated?(scope), "Expected #{scope} to not be authenticated." end |
#sign_in(user, options = {}) ⇒ Object
11 12 13 |
# File 'lib/janus/test_helper.rb', line 11 def sign_in(user, = {}) janus.login(user, ) end |
#sign_out(user_or_scope = nil) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/janus/test_helper.rb', line 15 def sign_out(user_or_scope = nil) if user_or_scope janus.logout(Janus.scope_for(user_or_scope)) else janus.logout end end |