Impossible to check that method is executed in a range times.
Created by: VitaliiLazebnyi
Subject of the issue
According to the documentation methods, at_least and at_most can be chained to have range check: method is called between N and M times. (at least N times and not more then M times). But rspec-mocks actually checks the last condition and ignores previous ones.
Your environment
- Ruby version: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux-gnu]
- rspec-mocks version: rspec-mocks (3.7.0)
Steps to reproduce
it "doesn't support double checks" do
tmp = double('Test Variable')
expect(tmp).to receive(:call).and_return(nil).at_least(1).at_most(2).times
end
it "doesn't support double checks" do
tmp = double('Test Variable')
expect(tmp).to receive(:call).and_return(nil).at_most(2).at_least(1).times
tmp.call
tmp.call
tmp.call
end
Expected behavior
Both tests should fail since one of the conditions is not followed.
Actual behavior
Both tests pass since the condition, which is at the end, overwrites the previous one.