thoughtbot/shoulda-matchers — pull request #271 by henning-koch (2013-03-26 13:05:42+00:00)
Title: Fix a bug where matchers fail on models with an autosaved belongs_to associations

When a model has an autosaved belongs_to associations, matchers fail when validating records of that model.

E.g. you have a `User` that `belongs_to` a `Group` and accepts nested attributes for that group:

```
class User < ActiveRecord::Base
accepts_nested_attributes_for :group
end

class Group < ActiveRecord::Base
validates_presence_of :name
end
```

When using one of the matchers on `User` records with a nameless group, `user.errors` has an entry for `group.name` (sic). The matcher tries to come up with a helpful error message that includes the value for `group.name` but of course fails because the user does not `respond_to?('group.name')`.

The attached pull request checks if a record responds to an error key before obtaining the attribute value for that key.

A new patch release would be greatly appreciated!

Thanks.