When using rspec in my rails projects, I often add :focus => true on describe/context/it block and let guard running the tests on those new specs. I need to remove it from various places to run the test fully. It’s a bit annoying, actually. Therefore, I decide to write a ruby script just to do this thing:
What this code does is checking all the spec directory to remove them on every describe/context/it block. You would see I use very strict regular expression just to ensure I’m doing the write thing. I placed this script under script directory of my rails app. You may write this code better, but this is how i do it. I also create a rake script and add to hg before commit hook.
namespace:specdodesc"remove :focus => true in all specs"task:remove_focusdorequire_relative'../../script/remove_focus'endend