Kerry Buckley

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

Helpful message from rspec

one comment

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.

Written by Kerry

May 4th, 2009 at 4:21 pm

Posted in rspec

Tagged with

One Response to 'Helpful message from rspec'

Subscribe to comments with RSS or TrackBack to 'Helpful message from rspec'.

  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.

Leave a Reply

You must be logged in to post a comment.