How to Test Rails Models with Minitest

In this tutorial, we will cover how to test Ruby on Rails models with the Minitest testing suite. After completing this tutorial, you will have learned the following:

  • What to test in Rails models,
  • How to test the various aspects of a Rails model, such as validations, associations, scopes, and extra business logic methods, and
  • How to use fixtures to refactor and simplify your model tests.

We will be using Ruby 2.3, Rails 5.0 and Minitest 5.8. However, older versions should have the same behavior. The only difference to note is that models in Rails 5.0 inherit fromApplicationRecord instead of ActiveRecord::Base.

How to Test Rails Models with Minitest #ruby #rails #rubyonrails #bosnia #programming #tutorials #rubydeveloper #railsdeveloper

Nezir Zahirovic

Contractor Ruby On Rails (7+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles