Rethink RSpec expectations with after and before hooks
Currently, following test example succeeds:
```ruby
context 'test' do
let(:test) { double }
it 'expects some message' do
expect(test).to receive(:xxx)
end
after do
test.xxx
end
end
```
It is also possible to set expectations in a `before` block.
This behavior is a little confusing, and in fact can lead to some problems, when we do a clean up in a `after` block. Example is https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/23223257 - we expect some messages sent to some object, but we receive more messages since we trigger a clean up in `after` block.
It does not seem right according to how I understand `before` and `after` semantics, but I might be wrong.
Does it warrant an issue in upstream project? :thinking:
What do you think @rymai @rspeicher?
issue