thoughtbot/shoulda-matchers — pull request #295 by pbrisbin (2013-05-24 15:17:52+00:00)
Title: Displays wrong failure message for `should validate_presence_of`

Maybe I'm being really dumb, but I've tried looking at this 12 different ways and I keep coming to the same conclusion, which is that Shoulda is displaying the wrong test failure message for `validate_presence_of`.

I am doing this is my test:

class ThingTest < ActiveRecord::TestCase
should validate_presence_of(:name)
end

I have not yet done `validates :name, presence: true` on the model, so my Thing model looks like this:

class Thing < ActiveRecord::Base
attr_accessible :name
end

When I run my tests, I get this test failure message:

test: Thing should require name to be set. (ThingTest)
Did not expect errors to include "can't be blank" when name is set to nil, got errors:

But shouldn't that second line read something along the lines of:

Expected errors to include "can't be blank" when name is set to nil, got errors:

Am I missing something?

I'm using shoulda 3.5.0, shoulda-context 1.1.1, and shouda-matchers 2.1.0. I set up a repo that demonstrates this behaviour: https://github.com/toasterlovin/shoulda-bug