|
4 | 4 | describe "initialize" do
|
5 | 5 | context "when instrumentation is configured" do
|
6 | 6 | 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 | + |
10 | 10 | @service = MockInstrumentationService.new
|
11 | 11 | end
|
12 | 12 |
|
|
16 | 16 | :instrumentation_service => @service
|
17 | 17 | end
|
18 | 18 |
|
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" |
24 | 21 |
|
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) |
29 | 27 |
|
30 | 28 | subject.bind.should be_true
|
31 | 29 |
|
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 |
39 | 33 | end
|
40 | 34 | end
|
41 | 35 | end
|
|
0 commit comments