I love having a proper terminal
One of things I love most about being on a Mac is having access to a proper Terminal shell. Not like the Windows Command Prompt which really is a sorry excuse for a shell in my mind.
In a project I am working on we have a couple of slightly similar controllers and as such the tests for these controllers are similar. Well I’ve written out the specs for one of these sets of controllers and now I need to make the ones for the others.
Now I could create each of these new files, copy the contents of other controllers tests across then find/replace the differences. But why should I have to do this.
Instead I can have my shell do it for me with
$ for parent in servers routers switches keyboard_video_mice power_supplies firewalls
> do cp ${parent}_nested_logins_controller_spec.rb \
${parent}_nested_change_logs_controller_spec.rb
> perl -pi -e 's/Login/ChangeLog/g' ${parent}_nested_change_logs_controller_spec.rb
> perl -pi -e 's/login/change_log/g' ${parent}_nested_change_logs_controller_spec.rb
> done
In a few short seconds I’ve fully spec’d out all ways in which my ChangeLogs controller is nested.
Brilliant. Course I could do this in FreeBSD/Linux too but they don’t look as pretty.