1

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?

Vega
  • 27,856
  • 27
  • 95
  • 103
Rimian
  • 36,864
  • 16
  • 117
  • 117

1 Answers1

5

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
Thomas
  • 1,613
  • 8
  • 8