Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple invocations of same method on a mock with minitest

I am using the version of minitest with Ruby 1.9.3 How do I test for multiple invocations of a mock with it? I need something like

mockObject.expect.times(2) :method, [return_1 first time, return_2 second time] 
mockObject.verify

Is there a way to achieve this?

like image 592
user949110 Avatar asked Nov 07 '14 16:11

user949110


1 Answers

You need to call expect for each time the method is to be called.

mockObject.expect :method, return_1, [first, time, args]
mockObject.expect :method, return_2, [second, time, args]

# run your code using the mock object

mockObject.verify
like image 72
blowmage Avatar answered Nov 15 '22 20:11

blowmage