RSpec argument contraints for any number of anything

911 views Asked by At

How to write correctly the expectation with matching first argument and ignoring other arguments? There can be any number of other arguments.

expect_any_instance_of(MyClass).to receive(:my_method).with('Argument', any_args)

I got this error:

RSpec::Mocks::MockExpectationError: #<MyClass:0x4589d604> received :my_method with unexpected arguments
  expected: ("Argument", any args)
       got: ("Argument", 0, 100, nil)

Why does it not matched the arguments?

Could you suggest a custom matcher for this?

0

There are 0 answers