Sha256: cb3452c29c57e5bc38599927895d8b22e3b5ac27e09833d2bc77cb7fb247281a

Contents?: true

Size: 904 Bytes

Versions: 4

Compression:

Stored size: 904 Bytes

Contents

# -*- ruby encoding: utf-8 -*-

describe Net::LDAP, "search method" do
  class FakeConnection
    def search(args)
      OpenStruct.new(:result_code => 1, :message => "error", :success? => false)
    end
  end

  before(:each) do
    @connection = Net::LDAP.new
    @connection.instance_variable_set(:@open_connection, FakeConnection.new)
  end

  context "when :return_result => true" do
    it "should return nil upon error" do
      result_set = @connection.search(:return_result => true)
      result_set.should be_nil
    end
  end

  context "when :return_result => false" do
    it "should return false upon error" do
      result = @connection.search(:return_result => false)
      result.should be_false
    end
  end

  context "When :return_result is not given" do
    it "should return nil upon error" do
      result_set = @connection.search
      result_set.should be_nil
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
net-ldap-0.7.0 spec/unit/ldap/search_spec.rb
net-ldap-0.6.1 spec/unit/ldap/search_spec.rb
net-ldap-0.6.0 spec/unit/ldap/search_spec.rb
net-ldap-0.5.1 spec/unit/ldap/search_spec.rb