Skip to content

Commit 42bdeb9

Browse files
committed
Add test case showing incorrect behaviour for failed searches
1 parent 7dd6c3a commit 42bdeb9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

spec/unit/ldap/search_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- ruby encoding: utf-8 -*-
2+
3+
describe Net::LDAP, "search method" do
4+
class FakeConnection
5+
def search(args)
6+
error_code = 1
7+
return error_code
8+
end
9+
end
10+
11+
before(:each) do
12+
@connection = Net::LDAP.new
13+
@connection.instance_variable_set(:@open_connection, FakeConnection.new)
14+
end
15+
16+
context "when returning result set" do
17+
it "should return nil upon error" do
18+
result_set = @connection.search(:return_result => true) do
19+
end
20+
result_set.should be_nil
21+
end
22+
end
23+
24+
context "when returning boolean" do
25+
it "should return false upon error" do
26+
success = @connection.search(:return_result => false)
27+
success.should == false
28+
end
29+
end
30+
end

0 commit comments

Comments
 (0)