[Feature request] assert_valid / refute_valid ActiveModel test helpers

This was proposed as an idea 4 years ago in https://github.com/rails/rails/pull/95. It was closed at that time, but I’d like to propose a refreshed version targeted towards ActiveModel and Minitest. The gem is at https://github.com/jch/minitest-model.

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



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