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
.
One reply on “Helpful message from rspec”
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.