Closed mcmire closed 4 years ago
Thanks for the quick work @mcmire! I was a little afraid when I originally commented that this project might be undermaintained, but I see that's far from the case.
Just in case you didn't see it: @pyrmont suggested an alternative solution that involves a double-assignment trick in https://github.com/thoughtbot/shoulda-context/issues/57#issuecomment-574918584. It has the same effect, and is maybe a little less gnarly. Totally up to you on which way to go though.
Thanks @brandur! I saw it just now and integrated it.
Nice! LGTM.
In converting a
should
within acontext
into a Minitest test (i.e. method), we have to make use ofclass_eval
. Inside of this eval we refer to the Context object that we're inside of, which means we have to set a variable outside of the eval. Unfortunately Ruby can't see into the eval so it thinks that variable has gone unused and emits a warning. The only real way to fix this is to make use of the variable somehow. Double assigning the variable seems to do the trick.Hat tip: @brandur, @pyrmont