Olá.
Exemplo de como usar a autenticação http básica para os testes sinatra ou grape api rspec:
def headers(options = {})
# Using gem 'choices' for define different auth
# configuration based on env.
username = options.fetch(:username, Rails.configuration.auth.username)
password = options.fetch(:password, Rails.configuration.auth.password)
{ 'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(username, password) }
end
def auth_get(route, params = {})
get route, params, headers
end