You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 30, 2024. It is now read-only.
I'm writing a small helper function for my test suite, and I'd like to protect both future me and my colleagues from using said method inside rspec's before(:all) hook (or extensions that run in the same context like let_it_be/before_all from test-prof). It just doesn't make sense to run it in that way.
The current way of detecting this context relies on the string output of self.inspect when running said method.
Alternatively, you can check the @__inspect_output instance variable.
The check looks like this:
# this lives in a module, included in the example groupdefmy_helper# self is an example group hereifinspect.include?("before(:context)")raisefriendly_errorend# do stuffend
You can see test-prof relying on the same hack here, and rspec-rails relying on it here.
Could we get an official way of detecting this context? It's easy to imagine this string changing w/o warning.