Sha256: b2fa10e597c29d775cb479d0e920140a414ec9da6102a22579f928680c90d3d7

Contents?: true

Size: 808 Bytes

Versions: 15

Compression:

Stored size: 808 Bytes

Contents

module AuthSpec
  def http_basic_login!
    request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials('usuario','senha')
  end
end

module CapybaraAuthSpec
  def http_basic_login!
    name = 'usuario'
    password = 'senha'
    if page.driver.respond_to?(:basic_auth)
      page.driver.basic_auth(name, password)
    elsif page.driver.respond_to?(:basic_authorize)
      page.driver.basic_authorize(name, password)
    elsif page.driver.respond_to?(:browser) && page.driver.browser.respond_to?(:basic_authorize)
      page.driver.browser.basic_authorize(name, password)
    else
      raise "I don't know how to log in!"
    end
  end
end

RSpec.configure do |config|
  config.include AuthSpec, type: :controller
  config.include CapybaraAuthSpec, type: :request
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pah-0.0.15 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.14 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.13 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.12 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.11 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.10 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.9 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.8 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.7 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.6 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.5 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.4 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.3 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.2 lib/pah/files/spec/support/http_basic_auth.rb
pah-0.0.1 lib/pah/files/spec/support/http_basic_auth.rb