Back on Task

What remains of our definition of done? is the distinction between complete and incomplete tasks. Let’s start with that, with a test for Task:

basics_rspec/03/gatherer/spec/models/task_spec.rb
​ 
require ​'rails_helper'​
​ 
​ 
RSpec.describe Task ​do​
​ 
it ​"can distinguish a completed task"​ ​do​
​ 
task = Task.new
​ 
expect(task).not_to be_complete
​ 
task.mark_completed
​ 
expect(task).to be_complete
​ 
​end​
​ 
​end​

This test makes two assertions, which I normally try to avoid, but the two assertions in this test are pretty intimately related—it would be awkward to separate them. We create a new Task (expecting that it is not complete at this point), then we complete the task and ...

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.