Fix Textmate’s Shoulda bundle broken shortcutes for deeply nested files
When you’re using Shoulda — and you should :) — on a Mac, you’re probably addicted to ⌘⇧R and ⌥⇧R shortcuts for running currently focused should/context.
That works rather well until your testfile is deeply nested (like in test/unit/my_module/something/complicated_test.rb) — then it falls on it’s face with Load Error: no such file to load — test_helper.
There is only one solution, and that is to tell Ruby to really, really include the test directory in $LOAD_PATH when running the script. One of the possible implementations of this solutions — and I am quite sure you’d come with much better one any moment — is this one.
Go to Bundles > Bundle Editor > Show Bundle Editor menu in TextMate and find the Ruby Shoulda bundle. Locate the Run Focused Should and Run Context entries and place the following snippet strategically at the bottom of the displayed shell script.
Notice how we drop to Ruby for massaging the TM_FILEPATH, a clear sign we’re no Unix geeks, no, mister.