Skip to content

Mock framework should be available in around hooks

gitlab-qa-bot requested to merge github/fork/pablobm/around-hooks-can-mock into master

Created by: pablobm

Problem: sometimes, the mocking framework is not available in the around hooks. On further inspection, we can see this only happens if the spec containing such an around hook is run first, before any other specs.

Reason: setup_mocks_for_rspec is called only after the around hook has started, and before the before hooks have run. Therefore, if the first spec to run has an around hook, this won't have access to the mocking framework. If this spec is run later instead, the mocking framework will have been activated by the time the around hook is reached.

The test case: I am providing one, but I'm not sure that's the place where you would want it. If you have any feedback, I'll be happy to relocate it.

Versions affected: this pull request is against master, but I initially experienced this problem with 2.14.7, where the patch is almost the same. If this is pull request is ok, I'll be happy to create another one for 2-14-maintenance, or whatever else necessary.

Merge request reports