Skip to content

Commit e34c6cc

Browse files
comandeo-mongojohnnyshieldsjamiscomandeo
committed
Fix CI (mongodb#5990)
Co-authored-by: Johnny Shields <27655+johnnyshields@users.noreply.github.com> Co-authored-by: Jamis Buck <jamis.buck@mongodb.com> Co-authored-by: Dmitry Rybakov <dmitry@rybakov.eu>
1 parent 3c87007 commit e34c6cc

File tree

3 files changed

+32
-19
lines changed

3 files changed

+32
-19
lines changed

gemfiles/standard.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
# rubocop:todo all
12
def standard_dependencies
23
gem 'rake'
34

45
group :development do
5-
gem 'yard'
6+
gem 'yard', '>= 0.9.35'
67

78
platform :mri do
89
# Debugger for VSCode.
@@ -15,10 +16,15 @@ def standard_dependencies
1516
# Evergreen configuration generation
1617
gem 'erubi'
1718
gem 'tilt'
19+
gem 'solargraph', platform: :mri
1820
end
1921

2022
group :development, :test do
2123
gem 'rspec', '~> 3.12'
24+
gem 'rubocop', '~> 1.45.1'
25+
gem 'rubocop-performance', '~> 1.16.0'
26+
gem 'rubocop-rake', '~> 0.6.0'
27+
gem 'rubocop-rspec', '~> 2.18.1'
2228

2329
platform :mri do
2430
gem 'byebug'
@@ -41,4 +47,8 @@ def standard_dependencies
4147
gem 'timeout-interrupt'
4248
end
4349
end
50+
51+
if ENV['FLE'] == 'helper'
52+
gem 'libmongocrypt-helper', '~> 1.8.0'
53+
end
4454
end

spec/support/expectations.rb

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,30 @@
22

33
module Mongoid
44
module Expectations
5-
6-
def connection_class
7-
if defined?(Mongo::Server::ConnectionBase)
8-
Mongo::Server::ConnectionBase
9-
else
10-
# Pre-2.8 drivers
11-
Mongo::Server::Connection
5+
# Previously this method used RSpec::Mocks with .exactly.times(n).and_call_original,
6+
# which stopped working reliably in Ruby 3.3. Now we directly wrap the target method.
7+
def expect_query(number)
8+
if %i[ sharded load-balanced ].include?(ClusterConfig.instance.topology) && number > 0
9+
skip 'This spec requires replica set or standalone topology'
1210
end
13-
end
1411

15-
def expect_query(number)
16-
rv = nil
17-
RSpec::Mocks.with_temporary_scope do
18-
if number > 0
19-
expect_any_instance_of(connection_class).to receive(:command_started).exactly(number).times.and_call_original
20-
else
21-
expect_any_instance_of(connection_class).not_to receive(:command_started)
12+
klass = Mongo::Server::ConnectionBase
13+
original_method = klass.instance_method(:command_started)
14+
query_count = 0
15+
16+
begin
17+
klass.define_method(:command_started) do |*args, **kwargs|
18+
query_count += 1
19+
original_method.bind_call(self, *args, **kwargs)
2220
end
23-
rv = yield
21+
22+
result = yield
23+
expect(query_count).to eq(number)
24+
result
25+
ensure
26+
klass.remove_method(:command_started)
27+
klass.define_method(:command_started, original_method)
2428
end
25-
rv
2629
end
2730

2831
def expect_no_queries(&block)

0 commit comments

Comments
 (0)