Run a Single Rails or Ruby Test from the Command Line

Posted by on Jan 15, 2013 in Blog, Geek, How To | One Comment

Sometimes when focusing on a specific area/method in a project, you may not want to run the full test suite every time you make a change. This is especially true in Rails projects, since tests can take a while to run.

Here’s how to run a single method of a test:

ruby -I test test/path/to/the_test.rb -n test_method_name

You can also run all tests in a single file with:

ruby -I test test/path/to/the_test.rb

The above works for Rails tests, since the test helper loads the Rails environment, but this is an alternative way to run tests in a single file in the context of Rails:

rake test TEST=test/path/to_file.rb

And as a general Rails testing note, if there are database issues, run db:test:prepare before running tests, (runs all database migrations).

For Sublime Text 2 users, the RubyTest package is worth a mention. It can run a single test or all tests from within Sublime: https://github.com/maltize/sublime-text-2-ruby-tests

2013 Word of the Year: Open

Posted by on Jan 12, 2013 in Blog, Geek, Life Experiments | No Comments

My word/manifesto/goal/guiding principle of 2012 was: “Create”

That still applies, but I thought it would be a good exercise to choose a new word for 2013. And that word is: “Open”.

This applies to my work: instead of hosting my side projects on private repositories, I will keep them public, whenever possible. (Doesn’t apply to work for my company or clients, of course!)

To kick that off, I’ve pushed a few repos:

First immediate benefit of working on a public repository: can’t take shortcuts like hard-coding API keys in my code (had to strip some of those out/change & invalidate API keys from some of the above repositories).


What about personally? What does it mean to be open?

  • It means less hesitation when talking about myself.
  • It means giving my honest thoughts & opinions whenever possible.
  • It means being more outgoing.
  • It means being more vulnerable to what other people think; it means worrying less about what other people think.
  • It means posting more of my writing publicly.
  • It means updating my blog more often.

I’m not really sure that this is a good idea, but I’m going to give it a shot.