Minitest Basics

Our project’s test directory contains Minitest equivalents of the RSpec tests we’ve written thus far.

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

minitest/01/gatherer/test/models/task_test.rb
​Line 1 
require ​'test_helper'​
​- 
​- 
​class​ TaskTest < ActiveSupport::TestCase
​- 
​5 
test ​"a completed task is complete"​ ​do​
​- 
task = Task.new
​- 
refute(task.complete?)
​- 
task.mark_completed
​- 
assert(task.complete?)
​10 
​end​
​- 
​- 
test ​"an uncompleted task does not count toward velocity"​ ​do​
​- 
task = Task.new(size: 3)
​- 
refute(task.part_of_velocity?)
​15 
assert_equal(0, task.points_toward_velocity)
​- 
​end​
​- 
​- 
test ...

Get Rails 4 Test Prescriptions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.