Instead of using
describe Foo do
# ...
end
use
RSpec.describe Foo, type: :model do
# ...
end
instead. This is not exactly official, as the former style still works,
but the latter style is highly suggested in RSpec documentation and the
like, so this is what people are used to.
[ci skip]
When the confirmation matcher is setting the confirmation attribute, we
want it to raise an exception if the model does not have that attribute,
same as if it would raise an exception if the attribute under test did
not exist.
This is part of a collection of commits that aim to improve failure
messages across the board, in order to make matchers easier to debug
when something goes wrong.
* Make the description of the matcher more readable.
Previously, `allow_value` failed when qualified with `with_message` and
the `:against` option. This also happened to propagate downward to
`validate_confirmation_of` since it uses `allow_value` + `:against`
(when a confirmation validation fails, it assigns the error message to
the *_confirmation attribute, not the attribute being confirmed).
This commit fixes both matchers.