RSpec errors when run en masse, but not individually

北城余情 提交于 2019-12-12 01:45:58

问题


Unfortunately I don't have a specific question (or clues), but was hoping someone could point me in the right direction.

When I run all of my tests (rspec spec), I am getting two tests that fail specifically related to Delayed Job.

When I run this spec file in isolation (rspec ./spec/controllers/xxx_controller_spec.rb) all the tests pass...... Is this a common problem? What should I be looking for?

Thanks!


回答1:


You are already mentioning it: isolation might be the solution. Usually I would guess that you have things in the database that are being changed and not cleaned up properly (or rather, are not not mocked properly).

In this case though I would suggest that, because the system is quite under a high workload, the delayed jobs are not being worked off fast enough. The challenge is with all asynchronous tasks that should be tested: you must not let the system run the delayed jobs, but mock the calls and just make sure that the delayed jobs have been received.

Sadly, with no examples, I can hardly point out the missing mocks. But make sure that all calls to delay_jobs and similar receive the correct data, but do not actually create and run those jobs - your specs will be faster, too. Make sure you isolate the function under test and not call external dependencies.



来源:https://stackoverflow.com/questions/10661629/rspec-errors-when-run-en-masse-but-not-individually

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!