Sha256: 8d90508f83deea52775a0252a75e240a85a3b9ed1959d0babe63670b92491529

Contents?: true

Size: 1.26 KB

Versions: 13

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe Net::LDAP::Connection do
  describe "initialize" do
    context "when host is not responding" do
      before(:each) do
        flexmock(TCPSocket).
          should_receive(:new).and_raise(Errno::ECONNREFUSED)
      end
      
      it "should raise LdapError" do
        lambda {
          Net::LDAP::Connection.new(
            :server => 'test.mocked.com', 
            :port   => 636)
        }.should raise_error(Net::LDAP::LdapError)
      end
    end
    context "when host is blocking the port" do
      before(:each) do
        flexmock(TCPSocket).
          should_receive(:new).and_raise(SocketError)
      end
      
      it "should raise LdapError" do
        lambda {
          Net::LDAP::Connection.new(
            :server => 'test.mocked.com', 
            :port   => 636)
        }.should raise_error(Net::LDAP::LdapError)
      end
    end
    context "on other exceptions" do
      before(:each) do
        flexmock(TCPSocket).
          should_receive(:new).and_raise(NameError)
      end
      
      it "should rethrow the exception" do
        lambda {
          Net::LDAP::Connection.new(
            :server => 'test.mocked.com', 
            :port   => 636)
        }.should raise_error(NameError)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 5 rubygems

Version Path
socialcast-net-ldap-0.1.7 spec/unit/ldap_spec.rb
socialcast-net-ldap-0.1.6 spec/unit/ldap_spec.rb
socialcast-net-ldap-0.1.5 spec/unit/ldap_spec.rb
net-ldap-0.3.1 spec/unit/ldap_spec.rb
net-ldap-0.3.0 spec/unit/ldap_spec.rb
prathe_net-ldap-0.2.20110317223538 spec/unit/ldap_spec.rb
prathe-net-ldap-0.2.20110317223538 spec/unit/ldap_spec.rb
net-ldap-0.2.2 spec/unit/ldap_spec.rb
net-ldap-0.2.1 spec/unit/ldap_spec.rb
net-ldap-0.2 spec/unit/ldap_spec.rb
scashin133-net-ldap-0.1.4 spec/unit/ldap_spec.rb
scashin133-net-ldap-0.1.3 spec/unit/ldap_spec.rb
scashin133-net-ldap-0.1.2 spec/unit/ldap_spec.rb