Sha256: f257736377b99821c018a29d55ba8d35d36fc58ef4c28253fc11e3cf34edbeef

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require 'simplecov'
SimpleCov.start do
  add_filter '/spec/'
  add_filter '/coverage/'
end

ENV["RAILS_ENV"] = "test"

require File.expand_path("rails_app/config/environment.rb",  File.dirname(__FILE__))
require 'rspec/rails'
require 'factory_girl_rails'

Dir[File.expand_path("support/**/*.rb", File.dirname(__FILE__))].each {|f| require f}


RSpec.configure do |config|
  config.mock_with :rspec
  config.infer_base_class_for_anonymous_controllers = false
end

def ldap_root
  File.expand_path('ldap', File.dirname(__FILE__))
end

def ldap_connect_string
  if ENV["LDAP_SSL"]
    "-x -H ldaps://localhost:3389 -D 'cn=admin,dc=test,dc=com' -w secret"
  else
    "-x -h localhost -p 3389 -D 'cn=admin,dc=test,dc=com' -w secret"
  end
end

def reset_ldap_server!
  if ENV["LDAP_SSL"]
    `ldapmodify #{ldap_connect_string} -f #{File.join(ldap_root, 'clear.ldif')}`
    `ldapadd #{ldap_connect_string} -f #{File.join(ldap_root, 'base.ldif')}`
  else
    `ldapmodify #{ldap_connect_string} -f #{File.join(ldap_root, 'clear.ldif')}`
    `ldapadd #{ldap_connect_string} -f #{File.join(ldap_root, 'base.ldif')}`
  end
end

def default_devise_settings!
  ::Devise.ldap_logger = true
  ::Devise.ldap_create_user = false
  ::Devise.ldap_update_password = true
  ::Devise.ldap_config = "#{Rails.root}/config/#{"ssl_" if ENV["LDAP_SSL"]}ldap.yml"
  ::Devise.ldap_check_group_membership = false
  ::Devise.ldap_check_attributes = false
  ::Devise.ldap_auth_username_builder = Proc.new() {|attribute, login, ldap| "#{attribute}=#{login},#{ldap.base}" }
  ::Devise.authentication_keys = [:email]
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise_ldap_norm-0.2.0 spec/spec_helper.rb