Rspec at_least after use with the condition does not work as I would expect

Is there a way to verify that a method is called at least once by matching arguments if the method is called in other cases with a different argument. Here is an example:

class A
  def test(a)
    puts "AAA"
  end
end

it "should work" do
  a = A.new
  expect(a).to receive(:test).with(1).at_least(:once)
  a.test 2
  a.test 1
  a.test 3
end

I'm just curious that the test is called at least once with a certain parameter, but I get a failure in the first call of the test with an argument that does not match.

UPDATE The best example of what I want to do is a bit more complicated than that ... I want to do custom mapping with parameters ... something more like

it "should work" do
  a = A.new
  expect(a).to receive(:test).at_least(:once).with(an_instance_of(Fixnum)) do |i|
    expect(i).to be > 2
  end
  a.test 2
  a.test 1
  a.test 3
end

mocha , with . false, , . , rspec ( and_call_original).

+3
1

, as_null_object, .

:

a = A.new

To:

a = A.new.as_null_object
0

All Articles