Skip to content

Commit f682231

Browse files
p-mongop
andauthored
RUBY-2220 add file name context to command monitoring spec (#2288)
Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent 3d24c92 commit f682231

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

spec/spec_tests/command_monitoring_spec.rb

+28-26
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,42 @@
99
describe 'Command Monitoring Events' do
1010

1111
COMMAND_MONITORING_TESTS.each do |file|
12+
context File.basename(file) do
1213

13-
spec = Mongo::CommandMonitoring::Spec.new(file)
14+
spec = Mongo::CommandMonitoring::Spec.new(file)
1415

15-
spec.tests.each do |test|
16-
context(test.description) do
16+
spec.tests.each do |test|
17+
context(test.description) do
1718

18-
if test.min_server_fcv
19-
min_server_fcv test.min_server_fcv
20-
end
21-
if test.max_server_version
22-
max_server_version test.max_server_version
23-
end
19+
if test.min_server_fcv
20+
min_server_fcv test.min_server_fcv
21+
end
22+
if test.max_server_version
23+
max_server_version test.max_server_version
24+
end
2425

25-
let(:subscriber) do
26-
EventSubscriber.new
27-
end
26+
let(:subscriber) do
27+
EventSubscriber.new
28+
end
2829

29-
let(:monitoring) do
30-
authorized_client.send(:monitoring)
31-
end
30+
let(:monitoring) do
31+
authorized_client.send(:monitoring)
32+
end
3233

33-
before do
34-
authorized_collection.find.delete_many
35-
authorized_client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
36-
end
34+
before do
35+
authorized_collection.find.delete_many
36+
authorized_client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
37+
end
3738

38-
test.expectations.each_with_index do |expectation, index|
39+
test.expectations.each_with_index do |expectation, index|
3940

40-
it "generates a #{expectation.event_name} for #{expectation.command_name}" do
41-
begin
42-
test.run(authorized_collection, subscriber)
43-
check_event(subscriber, index, expectation)
44-
rescue Mongo::Error::OperationFailure, Mongo::Error::BulkWriteError
45-
check_event(subscriber, index, expectation)
41+
it "generates a #{expectation.event_name} for #{expectation.command_name}" do
42+
begin
43+
test.run(authorized_collection, subscriber)
44+
check_event(subscriber, index, expectation)
45+
rescue Mongo::Error::OperationFailure, Mongo::Error::BulkWriteError
46+
check_event(subscriber, index, expectation)
47+
end
4648
end
4749
end
4850
end

0 commit comments

Comments
 (0)