[Feature request] assert_valid / refute_valid ActiveModel test helpers

This was proposed as an idea 4 years ago in Added assert_valid for ActiveSupport::TestCase by stjhimy · Pull Request #95 · rails/rails · GitHub. It was closed at that time, but I’d like to propose a refreshed version targeted towards ActiveModel and Minitest. The gem is at GitHub - jch/minitest-model: Test assertions for ActiveModel and ActiveRecord.

This feature is more useful today than when it was originally proposed because any ActiveModel::Validations standardized the interface used by ORMs and general ruby objects. Here is a sample of what it looks like:

class MyTest < ActiveSupport::TestCase include Minitest::Model

test “model requires email” do m = Model.new refute_valid m, :email

m.email = "foo@bar.com"
assert_valid m, :email

end end

``

Failed assertions print a descriptive message of why it failed rather than a generic “Expected true” if asserting on just valid?.

Thanks!

-Jerry