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
class Group < ActiveRecord::Base
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!
fix a bug where matchers would fail on models with an autosaved belon…
Thanks @henning-koch! Merged.