Merge pull request #24 from danabr/default_search_behaviour

search should return result set if :return_result is unspecified (nil).
This commit is contained in:
Rory O'Connell 2011-10-07 05:14:08 -07:00
commit 6bb9fa6ae6
2 changed files with 12 additions and 4 deletions

View file

@ -619,7 +619,8 @@ class Net::LDAP
end
args[:base] ||= @base
result_set = args[:return_result] == false ? nil : []
return_result_set = args[:return_result] != false
result_set = return_result_set ? [] : nil
if @open_connection
@result = @open_connection.search(args) { |entry|
@ -642,7 +643,7 @@ class Net::LDAP
end
end
if args[:return_result]
if return_result_set
@result == 0 ? result_set : nil
else
@result == 0

View file

@ -13,17 +13,24 @@ describe Net::LDAP, "search method" do
@connection.instance_variable_set(:@open_connection, FakeConnection.new)
end
context "when returning result set" do
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 returning boolean" do
context "when :return_result => false" do
it "should return false upon error" do
success = @connection.search(:return_result => false)
success.should == 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