Fixing my autotest after switching to Rails 3.1.0

In my last post, I complained about autotest being broken. Well, it’s not actually broken. I’ve just fixed my problem, and it turned out to be one of the perils of the way I went about the conversion of my project to the new version of Rails, and not at all related to the Rails upgrade or the autotest gems.

The Missing Piece
The missing piece was that in my new project folder, I didn’t have a .rspec file. That file contains one crucial line of code, --drb. That’s all. (Ok, I actually have a second line in mine, --color to show red/yellow/green for fail/pending/pass, but that’s not the important part.)

That one invisible file with the one short line of code is, approximately, the connection that allows spork to load the project for testing and allows autotest to recognize the location of the tests. The rspec wiki page regarding autotest explains that having a .rspec file in the project root “tells RSpec to tell Autotest to load RSpec’s autotest extension.” Thank goodness I found the advice of the third responder on a year-old StackOverflow question!

How It Happened
This problem was only tangentially related to my Rails version upgrade. Because I created a fresh project and copied over only the relevant bits of the code, it was easy for me to miss the invisible .rspec file. (For my fellow noobs, any file or folder beginning with a period will be invisible in the default file navigation view of your system. A lot of system files are named this way to prevent people accidentally altering them.) By copying over most of the code I needed, I may have actually blocked myself a bit. I think that if I had set up RSpec properly, it would have created the file for itself based on my system-wide preferences for it. The dangers of cutting corners, eh?


About joanwolk

3 things I like: theater, food, geekery. 3 things I don't like: clichés, blisters, coffee.
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Fixing my autotest after switching to Rails 3.1.0

  1. Pingback: Rails 3.1.0.beta1 | git init and get in it!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s