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.