Ruby Mocha 期望第一个参数是一个符号

Ruby Mocha expect the first argument to be a symbol

我试图断言方法调用发生在第一个参数是符号的地方,如下所示:

Foo.bar(:some_key, {})

现阶段我不太关心第二个参数是什么。

我试过:

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

和文档中发现的其他变体 here。当我期望带有任何参数的方法调用时,测试通过。

有什么想法吗?

你试过这个吗:

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

如果您需要更具体,您也可以使用块:

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