mardi 6 septembre 2016

Using expects().twice.with().returns using Mocha, Rails

I am using mocha to mock my tests.

Here is an example of what I am trying to do.

ClassName.expects(:method_name).twice.with() do |options|
  options == input_options1 || options == input_options2
end.returns("abc123", "def456")

The above works.

But is there another way, where I can specify two different types on input_options, something like,

ClassName.expects(:method_name).twice.with(input_options1,input_options2).returns("abc123", "def456")

where my function "method_name" accepts only one parameter.

Aucun commentaire:

Enregistrer un commentaire