From 42bdeb93d8597fbbb9ae42e6090325f604f14d8c Mon Sep 17 00:00:00 2001 From: Daniel Abrahamsson Date: Thu, 22 Sep 2011 15:55:13 +0200 Subject: [PATCH] Add test case showing incorrect behaviour for failed searches --- spec/unit/ldap/search_spec.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spec/unit/ldap/search_spec.rb diff --git a/spec/unit/ldap/search_spec.rb b/spec/unit/ldap/search_spec.rb new file mode 100644 index 0000000..b00ae98 --- /dev/null +++ b/spec/unit/ldap/search_spec.rb @@ -0,0 +1,30 @@ +# -*- ruby encoding: utf-8 -*- + +describe Net::LDAP, "search method" do + class FakeConnection + def search(args) + error_code = 1 + return error_code + end + end + + before(:each) do + @connection = Net::LDAP.new + @connection.instance_variable_set(:@open_connection, FakeConnection.new) + end + + context "when returning result set" do + it "should return nil upon error" do + result_set = @connection.search(:return_result => true) do + end + result_set.should be_nil + end + end + + context "when returning boolean" do + it "should return false upon error" do + success = @connection.search(:return_result => false) + success.should == false + end + end +end