Sha256: 332aa643538f59e02e833ca2bb22ffca9f0bba434dba5efebb9b1fd31a411fab

Contents?: true

Size: 774 Bytes

Versions: 2

Compression:

Stored size: 774 Bytes

Contents

module Janus
  module TestHelper
    attr_reader :janus

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

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

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

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

    def refute_authenticated(scope)
      refute janus.authenticated?(scope), "Expected #{scope} to not be authenticated."
    end

    alias_method :assert_not_authenticated, :refute_authenticated
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
janus-0.10.1 lib/janus/test_helper.rb
janus-0.10.0 lib/janus/test_helper.rb