Sha256: 936dca5327e4a76fac6572675bafe5085693f16687cb3ebb6918b51bfd84279b

Contents?: true

Size: 693 Bytes

Versions: 5

Compression:

Stored size: 693 Bytes

Contents

module Janus
  module TestHelper
    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 assert_not_authenticated(scope)
      assert !@janus.authenticated?(scope), "Expected #{scope} to not be authenticated."
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
janus-0.9.1 lib/janus/test_helper.rb
janus-0.9.0 lib/janus/test_helper.rb
janus-0.8.1 lib/janus/test_helper.rb
janus-0.8.0 lib/janus/test_helper.rb
janus-0.7.0 lib/janus/test_helper.rb