Sha256: 73636416efdcdd963e2ebf0c46627e5af672eb430537c5134ff14fe1aeafb4ae

Contents?: true

Size: 758 Bytes

Versions: 4

Compression:

Stored size: 758 Bytes

Contents

module ControllerTestHelpers
  def visit(action, params = {}, options = {})
    method = options.delete(:method) || :get

    user = ENV["RESQUE_WEB_HTTP_BASIC_AUTH_USER"]
    password = ENV["RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD"]

    if options[:auth] == :disabled
      ENV["RESQUE_WEB_HTTP_BASIC_AUTH_USER"] = nil
      ENV["RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD"] = nil
    else
      request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(
        options[:user] || user, options[:password] || password
      ) unless options[:auth] == false
    end

    send(method, action, params: params)

    ENV["RESQUE_WEB_HTTP_BASIC_AUTH_USER"] = user
    ENV["RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD"] = password
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
misha-resque-web-0.1.1 test/support/controller_test_helpers.rb
misha-resque-web-0.1.0 test/support/controller_test_helpers.rb
misha-resque-web-0.0.9 test/support/controller_test_helpers.rb
resque-web-0.0.9 test/support/controller_test_helpers.rb