Kerry Buckley What’s the simplest thing that could possibly go wrong?

4 May 2009

Helpful message from rspec

Filed under: rspec — Tags: — Kerry Buckley @ 4:21 pm

Just came across an interesting error message from rspec. I had a spec that looked like this:

it "should not mass-assign 'confirmed'" do
  Blog.new(:confirmed => true).confirmed.should_not be_true
end

Obviously it failed, as I hadn’t written the code yet, but there was more in the error message than I expected:

..........F

1)
RuntimeError in 'Blog should not mass-assign 'confirmed''
'should_not be  true' not only FAILED,
it is a bit confusing.
It might be more clearly expressed in the positive?
.../spec/models/blog_spec.rb:20:

Finished in 0.06192 seconds

11 examples, 1 failure

In fact, rewriting this as should be_false wouldn’t work, as the expected value is nil. I took the hint though, and rewrote it as should be_nil.

1 Comment »

  1. I think I was introduced to this one as the Stroop Effect on the Google Testing Blog about a year ago: http://googletesting.blogspot.com/2008/02/tott-stroop-effect.html

    Funny that it was incorporated into rspec. This one should be included in every testing framework from my point of view.

    Comment by Markus Gärtner — 4 May 2009 @ 5:45 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress