Wrong negative expectation with once
Created by: syarinovskiy
Hello. I have such tests:
class A; end
it 'calls new' do
expect(A).to receive(:new).once
A.new
end
It finishes successfully. Next one:
class A; end
it 'calls new' do
expect(A).not_to receive(:new)
# A.new
end
Also fine. But if I combine .not_to
with .once
it behaves like it expects to receive:
class A; end
it 'calls new' do
expect(A).not_to receive(:new).once
# A.new
end
Failure/Error: expect(A).not_to receive(:new).once
(A (class)).new(*(any args))
expected: 1 time with any arguments
received: 0 times with any arguments
I am not sure if this is a bug. I would expect that .once
will be ignored and last test passes
rspec-mocks (3.7.0)
Thank you