1

First, the big picture. I'm writing a sinatra-based web app. One thing it's going to do is determining users' birth years. For that it interacts with the other app. It first asks the user's data, like first name, last name, sex, birthday (month and day), whatever. And then makes search requests with all these data plus some year (2015, 2014, so on). If it gets this particular user in response, than that year is his birth year.

The easy way to test it is to simply ensure sleep is called at least once, like so:

it 'makes delays' do
  expect_any_instance_of(Object).to receive(:sleep).with(gte(1)).at_least(:once)
  stub_requests
  DetermineBirthYearJob.perform ...
end

Any more thorough testing seems to be a hassle. Will the test above suffice? If not, how to test this particular behavior?

P.S. Answers in languages other than ruby are also welcome, as are language-agnostic answers.

x-yuri
  • 16,722
  • 15
  • 114
  • 161
  • 1
    There isn't really any other more direct way to test whether a method was called or not. There's no problem here, other than maybe your app sleeping on the job. – DiegoSalazar Jan 06 '15 at 17:17
  • The question is whether it makes sense to try and test if method is called between requests, or even between every two successive requests? – x-yuri Jan 06 '15 at 17:34

0 Answers0