A Small Bug in RSpec 0.5.13

I’m doing a recreational Rails project in my infrequent spare time and using RSpec as well. After generating a controller for the

1
Game

class I noticed it failed on a very simple specification.

controller.should_be_an_instance_of GameController

The failure message was:

undefined method 'an_instance_of?' for #<GameController:0x222df78>

That looked pretty wrong. Why was it trying to call

1
an_instance_of?

. It turns out

1
a

and

1
an

are just syntactic sugar methods that just return

1
self

. So just for fun I changed to the dot notation without the underscore sugar.

controller.should.be.an.instance.of GameController

That passed with flying colors. OK, so now I know it’s just an issue with the underscores. Writing a spec to show the issue was fairly simple:

context "Underscore Example Error" do
  specify "should_be_an_instance_of fails with underscore notation" do
    lambda { "example".should_be_an_instance_of String }.should_raise NoMethodError
  end
  specify "should.be.an.instance.of fails with underscore notation" do
    lambda { "example".should_not_be_an_instance_of Fixnum }.should_raise NoMethodError
  end
  specify "should_be_a_kind_of should fails underscore notation" do
    lambda { "example".should_be_a_kind_of Object }.should_raise NoMethodError
  end
  specify "should.not_be_a_kind_of fails with underscore notation" do
    lambda { "example".should_not_be_a_kind_of Fixnum }.should_raise NoMethodError
  end   
end

The bug appears to be with the following method in

def method_missing(sym, *args, &block)
        if __is_sweetened? sym
          object = self
          calls = sym.to_s.split("_")
          while calls.length > 1
            call = calls.shift
            object = object.__send__(call)
            break if call == "be"
          end
          return object.__send__(calls.join("_"), *args, &block)
        end
        __orig_method_missing(sym, *args, &block)
      end

Hopefully tonight I’ll have time to code up a quick suggested patch and submit it. First I have to download a few gems and run the tests specs for RSpec to see if I might have broken something else with my fix.

I’m enjoying forcing myself to really think about contexts, specifications, and should statements instead of tests. I think I could probably accomplish about the same thing with good old

1
Test::Unit

, but forcing your brain to think down a different path can sometimes change your perspective.

Bring a Laptop to Your Interview

Apparently the Java developers market in Sacramento is heating up these days with about 20+ positions largely contracting for between $45-$75/hr. On that note one of the developers in the audience mentioned that he was doing a lot of interviewing and that bringing actual code on a laptop to an interview would really impress him, though he hadn’t seen anyone actually do that. As a hiring manager I can vouch that I would be impressed with someone who did that in an interview.

Beyond that at the SACJUG meeting Nick Chalko did a good overview of the TPTP plugin for Eclipse 3.2. Some of my developers are starting to look more into profiling so the overview was helpful. I’ve also heard that the new NetBeans has a really nice profiler.

Rails and RSpec over Lunch

With two small children at home I’ve lately been trying to get in about an hour of coding around lunch. These days thats Ruby on Rails and RSpec. I spent about half an hour today trying to figure out why RSpec was failing on the following:

"bob".should_be "bob"

Seemed reasonable especially since the following passed fine:

2.should_be 2

These were really simplified examples I came to after about the first 15 minutes. Turns out I found the answer by paying closer attention to the RSpec API. It turns out should_be calls the equal? method not the == method. Worked fine with:

"bob".should_be_equal "bob"

I’m enjoying trying out RSpec with Rails so far, though the startup time to run the specs is about 8-10 seconds on my laptop which is a bit annoying.

Bringing In Mentoring Consultants

Bruce Eckel related some enlightening evidence that many organizations aren’t comfortable bringing in a high end experience consultant to help review their code and architectures:

Reference

In all the years that I have offered design reviews, code reviews, and walkthroughs, only one client has ever used these services.

I can second that anecdotal advice. In about five years of doing professional services I only had one client who ever brought us in to review their architecture. The sad reality is there is really valuable information to be gleaned through this process, but very few organizations are up to using it. Much easier to send some people to a training class or bring in a contractor to cover a narrow role on a single project.

If you bring in a consultant to review your code and design they just might tell you that something is wrong, and that’s difficult.

Office to Team Room

At the suggestion of a developer I’ve revisited the idea of turning my office into a true team room. After about 6 months in the cube farm my office is pretty much just used as a team room anyway. Here’s the current office:

The current layout has a few issues:

  • One whole wall is locked out from whiteboard/corkboards due to some cubicle bookshelves.
  • No table for longer meetings. It works fine for standups, but after 15 minutes you might want to sit down.
  • The shelves along the north wall block easy access to the corkboard, so people have to reach to move around there tasks into the ‘tested/done’ column.

Here’s my team room concept:

With a little luck and the help of an admin who’s passionate about rethinking our space, I may be able to pull this off.