Topic: test method called

I'm writing a unit test which calls some dependency n times

ie list.each { |x| dependency.method(x) }

I want to assert that this method was called n times.  Is there a way I should do that?

My real use case is that I have an object that calls out to an ActionMailer for each item in a list.

Re: test method called

Am do you mean this:
i = 0
list.each do |x|
  dependency.method(x)
  i+=1
end
puts i

Re: test method called

I'd like to have a unit test for a method that does the iteration and the subsequent call to the dependency's method. so adding testing logic in my actual code won't work

Last edited by alexk82 (2010-09-01 10:12:51)