Rails Test Prescriptions Blog

Keeping Your Application Healthy Since 2008

August 11, 2010: An Abundance of Options

Book Status

Shoulda chapter fixes made. The next decision is whether to push that as a beta by itself, or wait until the RSpec chapter is also done.

Also

Today is the last day to get early bird pricing for WindyCityRails.

Book Status

I did not know that Ruby 1.9 had its own coverage tool. Aaron Patterson shows how to use that tool and a little code to create useful output for coverage testing.

I’m really happy to see some discussion of what good style is for Cucumber tests. Jonas Nicklas argues in favor of what I call in the book the implicit style of testing. He closes with “A step description should never contain regexen, CSS or XPath selectors, any kind of code or data structure”. I think that’s got it right. I was just deciding not to add a Cucumber/Factory add-on to my project and decided not too for reasons articulated pretty well by Jonas. The goal of Cucumber is not to write as few step-definitions as possible.

Dane Harrigan discusses handling Rails exceptions from Ajax calls. It involves what may be the first actual use case of an around_filter I’ve ever seen.

Xavier Shay argues that database constraints make it easier for new developers to understand your code. Hmm… I tend to be not a fan of database constraints. Or more accurately, I tend to be very cognizant of the development costs of adding database constraints, so I only add them when they seem necessary. It’s hard to argue, though with the idea that the code and database should not actually conflict.

The Silence is Foo blog gives an almost obsessive amount of love to the splat operator. Yay! The splat operator is one of my favorite corners of Ruby (as it was one of my favorite corners of Python). Even so, I learned a couple of new splat tricks from this article.

I’ll close here with a little debate on choices in Ruby and Rails. Kevin Gisi has a satirical little number on how hard it is to be a new Ruby developer and choose among the various options for everything. Peter Cooper at Rails inside offers not a rebuttal exactly, but a slightly different take on the issue. Kevin is obviously writing tongue-in-cheek, so you can’t exactly get worked up about him going overboard, and I agree with Peter’s take that things could be improved with better presentation. I do think that both Ruby and Rails have gotten a bit less novice friendly (as many projects do over time as complexity gets added). I don’t think it’s an unsolvable problem, but we can always make it easier for new people to come on board.

Advertisements

4 responses to “August 11, 2010: An Abundance of Options

  1. Brandon August 11, 2010 at 3:21 pm

    +1 to push the Shoulda chapter as a beta by itself. That chapter is the reason I bought the beta

  2. Jonathan O'Connor August 24, 2010 at 4:23 am

    Noel,
    I tried the Coverage class on our Rails 2.3.8 app running under 1.9.1, and the hash does not contain any of my model or controller classes, unless I explicitly do a Model.new or Controller.new in the coverage setup code.

    The weird thing is that all my tests run correctly, and Coverage picks up all the Rails code, but I’m wondering if Rails has some funny mechanism for reading all the ruby files in app/** and so they are not appearing.

    Sadly nobody else seems to have this problem. I also wonder if it is a problem with my machine setup and rvm. As a relative Ruby Newbie, I can’t rule that out 😦

    • noelrap August 24, 2010 at 6:44 am

      Gosh, I don’t know. My hands on experience with Ruby 1.9.x is pretty minimal so far. Offhand, I’d try upgrading to 1.9.2 final, since that should be more stable, but beyond that, I’m just not sure.

  3. Jonathan O'Connor August 24, 2010 at 6:58 am

    Noel,
    yes that was what I was next going to try. But living out in the middle of nowhere in Ireland, with a dodgy broadband connection, doing all those gem installs fills me with trepidation. But that’s another story.

    If I do solve it, I’ll let you know, and keep up with the book, it’s great reading.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: