O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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
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 ​"a task completed long ago does not count toward velocity"​ ​do
task = Task.new(size: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required