Adding Some Math
Moving on. Next, you need to be able to calculate how much of a project is remaining and the rate of completion, and then put them together to determine a projected end date.
The next test is for the project to be able to calculate how much work is remaining.
I like to take a moment before I write a test to think about what the test needs. The typical test structure has three parts:
-
Given: What data does the test need? This test needs a project, at least one complete task, and at least one incomplete task.
-
When: What action is taking place? I’m calculating the remaining work.
-
Then: What behavior do I need to specify? The work-calculation result.
I also like to think about what could make the happy-path test fail; that’s more ...
Get Rails 5 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.