I usually test my validations like this:
------------------
require "minitest_helper"
describe User do
it "rejects a bad password in validation" do
user = Factory.build(:user, :password_confirmation => 'Not my password')
user.invalid?(:password_confirmation).must_equal true
user.errors[:password_confirmation].must_equal "Password doesn't match
confirmation"
end
end
------------------
I don't usually check the error message itself, so no guarantees on that
part of the code.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/KCxjRSkTs3wJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.