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.