Sha256: e0ee50789634c72763f575359d87186c479c02a6d66258b8acc2a10cc72af689

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

# Add 'lib' to load path.
require 'test/unit'
require 'net/ldap'
require 'flexmock/test_unit'

# Whether integration tests should be run.
INTEGRATION = ENV.fetch("INTEGRATION", "skip") != "skip"

if RUBY_VERSION < "2.0"
  class String
    def b
      self
    end
  end
end

class MockInstrumentationService
  def initialize
    @events = {}
  end

  def instrument(event, payload)
    result = yield(payload)
    @events[event] ||= []
    @events[event] << [payload, result]
    result
  end

  def subscribe(event)
    @events[event] ||= []
    @events[event]
  end
end

class LDAPIntegrationTestCase < Test::Unit::TestCase
  # If integration tests aren't enabled, noop these tests.
  if !INTEGRATION
    def run(*)
      self
    end
  end

  def setup
    @service = MockInstrumentationService.new
    @ldap = Net::LDAP.new \
      host:           ENV.fetch('INTEGRATION_HOST', 'localhost'),
      port:           389,
      admin_user:     'uid=admin,dc=rubyldap,dc=com',
      admin_password: 'passworD1',
      search_domains: %w(dc=rubyldap,dc=com),
      uid:            'uid',
      instrumentation_service: @service
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
net-ldap-0.9.0 test/test_helper.rb