I've added the following allow statement to spec_helper.rb to fix an issue in my codebase where tons of specs had added expect().receive on the metrics class making tests brittle to new metrics calls in underlying classes.
allow(MetricsClass).to receive(:increment).with(any_args)
Unfortunately, I'm running in errors
ArgumentError: Wrong number of arguments. Expected 1, got 2.
The function definition:
def self.increment(counter_name, by: 1, **tags)
The line in the code where this failure happens:
MetricsClass.increment("string", **info)
Info itself is a hash
puts info
{"class/method"=>true}
ruby 2.7.6 rspec 3.12.0
Relevant RSpec configuration:
RSpec.configure do |config|
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
end