Skip to content

Commit 84dfde7

Browse files
committed
Spec out Net::LDAP#bind instrumentation
Pretty much removes what was there before since it was re-specing Net::LDAP::Connection#bind and wire level instrumentation.
1 parent 08dad42 commit 84dfde7

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

spec/unit/ldap_spec.rb

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
describe "initialize" do
55
context "when instrumentation is configured" do
66
before do
7-
@tcp_socket = flexmock(:connection)
8-
@tcp_socket.should_receive(:close)
9-
flexmock(TCPSocket).should_receive(:new).and_return(@tcp_socket)
7+
@connection = flexmock(:connection, :close => true)
8+
flexmock(Net::LDAP::Connection).should_receive(:new).and_return(@connection)
9+
1010
@service = MockInstrumentationService.new
1111
end
1212

@@ -16,26 +16,20 @@
1616
:instrumentation_service => @service
1717
end
1818

19-
it "should set the service object and instrument network calls" do
20-
@tcp_socket.should_receive(:write).and_return(bytes_written = 1)
21-
22-
write_events = @service.subscribe "write.net_ldap_connection"
23-
read_events = @service.subscribe "read.net_ldap_connection"
19+
it "should instrument bind" do
20+
events = @service.subscribe "bind.net_ldap"
2421

25-
ber = Net::BER::BerIdentifiedArray.new([0, "", ""])
26-
ber.ber_identifier = Net::LDAP::PDU::BindResult
27-
read_result = [2, ber]
28-
@tcp_socket.should_receive(:read_ber).and_return(read_result)
22+
# ber = Net::BER::BerIdentifiedArray.new([0, "", ""])
23+
# ber.ber_identifier = Net::LDAP::PDU::BindResult
24+
# Net::LDAP::PDU.new([0, ber])
25+
bind_result = flexmock(:bind_result, :success? => true)
26+
@connection.should_receive(:bind).with(Hash).and_return(bind_result)
2927

3028
subject.bind.should be_true
3129

32-
# a write event
33-
payload, result = write_events.pop
34-
result.should == bytes_written
35-
36-
# then a read event
37-
payload, result = read_events.pop
38-
result.should == read_result
30+
payload, result = events.pop
31+
result.should be_true
32+
payload[:bind].should == bind_result
3933
end
4034
end
4135
end

0 commit comments

Comments
 (0)