Sha256: 7753afc7c21879f63f3fe75fbcd76ad52c1731bcc3923f3af1e8ab71f9dcecce

Contents?: true

Size: 1.22 KB

Versions: 9

Compression:

Stored size: 1.22 KB

Contents

module Authlogic
  module TestCase
    # Basically acts like a controller but doesn't do anything. Authlogic can interact
    # with this, do it's thing and then you can look at the controller object to see if
    # anything changed.
    class MockController < ControllerAdapters::AbstractAdapter
      attr_accessor :http_user, :http_password, :realm
      attr_writer :request_content_type

      def initialize
      end

      def authenticate_with_http_basic
        yield http_user, http_password
      end

      def authenticate_or_request_with_http_basic(realm = "DefaultRealm")
        self.realm = realm
        @http_auth_requested = true
        yield http_user, http_password
      end

      def cookies
        @cookies ||= MockCookieJar.new
      end

      def cookie_domain
        nil
      end

      def logger
        @logger ||= MockLogger.new
      end

      def params
        @params ||= {}
      end

      def request
        @request ||= MockRequest.new(controller)
      end

      def request_content_type
        @request_content_type ||= "text/html"
      end

      def session
        @session ||= {}
      end

      def http_auth_requested?
        @http_auth_requested ||= false
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
authlogic-4.5.0 lib/authlogic/test_case/mock_controller.rb
authlogic-4.4.3 lib/authlogic/test_case/mock_controller.rb
authlogic-4.4.2 lib/authlogic/test_case/mock_controller.rb
authlogic-4.4.1 lib/authlogic/test_case/mock_controller.rb
authlogic-4.4.0 lib/authlogic/test_case/mock_controller.rb
authlogic-4.3.0 lib/authlogic/test_case/mock_controller.rb
authlogic-4.2.0 lib/authlogic/test_case/mock_controller.rb
authlogic-4.1.1 lib/authlogic/test_case/mock_controller.rb
authlogic-4.1.0 lib/authlogic/test_case/mock_controller.rb