Minitest Basics

Your project’s test directory contains Minitest equivalents of many of the RSpec tests you’ve written thus far.

Here’s an example—specifically, the tests for the Task model:

1: require ​"test_helper"
class​ TaskTest < ActiveSupport::TestCase
test ​"a completed task is complete"​ ​do
5:  task = Task.new
refute(task.complete?)
task.mark_completed
assert(task.complete?)
end
10: 
test ​"an uncompleted task does not count toward velocity"​ ​do
task = Task.new(​size: ​3)
refute(task.part_of_velocity?)
assert_equal(0, task.points_toward_velocity)
15: end
test ​"a task completed long ago does not count toward velocity"​ ​do
task = Task.new(​size: ...

Get Rails 5 Test Prescriptions now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.