Ruby Mocha expect the first argument to be a symbol

447 Views Asked by At

I'm trying to assert a method call happens where the first argument is a symbol like so:

Foo.bar(:some_key, {})

I don't really care what the second argument is at this stage.

I've tried:

Foo.expects(:bar).with(includes(:some_key))

and other variations found in the documentation here. The test passes when I expect the method call with any arguments.

Any ideas?

1

There are 1 best solutions below

0
Thomas On BEST ANSWER

Have you tried this :

Foo.expects(:bar).with(:some_key, anything)

If you need to be more specific you can also use a block :

Foo.expects(:bar).with do |first_arg, second_arg|
  first_arg == :some_key
end