Skip to content
GRoguelon edited this page Sep 15, 2014 · 4 revisions

This page will try to show all usages available of the gem minitest-rails-assertion.

Assertions

There is all assertion test methods available:

  • assert_absence_of ;
  • assert_acceptance_of ;
  • assert_associated ;
  • assert_confirmation_of ;
  • assert_exclusion_of ;
  • assert_format_of ;
  • assert_inclusion_of ;
  • assert_length_of ;
  • assert_numericality_of ;
  • assert_presence_of ;
  • assert_uniqueness_of ;
  • assert_validates ;
  • assert_validator.

Usages

General

All assertions having the format assert_*_of must be used like this:

# app/models/product.rb
class Product < ActiveRecord::Base
  validates_presence_of :name, allow_nil: true
end

# test/models/product_test.rb
require 'test_helper'

class ProductTest < ActiveSupport::TestCase
  test 'attribute name must be present' do
    assert_presence_of Product, :name, allow_nil: true
  end
end
Clone this wiki locally