Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
3 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d475467
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is assert_valid being depreciated? I find it’s listing of validation errors to be very useful in testing.
assert @model.valid? is just going to show generically that true is not false, yes? Or am I missing something?
d475467
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yyyc514:
assert
takes another argument that is called for inspection when it fails. Something like this should work:d475467
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was supposed to be removed a while back, but we forgot about it.
d475467
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I knew assert took another argument but I never though of using it in such a fashion… rather obvious in hindsight. :-) And easy enough to code one’s own assert_valid to do just that I suppose.
d475467
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using
assert @model.valid?, @model.errors
doesn't print anything useful, as it just prints: #ActiveModel::Errors:0x007fedc685ea60I still can't see why this was depreciated and removed.
d475467
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is probably a little more useful, and can be put into your test/test_helper.rb file.
I'm a little unclear on why this was removed as well, as it seems like it is a pretty useful feature.