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

Adding Some Math

Moving on. We 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.

Now that we have the basic infrastructure in place, we can go a little bit faster, which manifests itself in a test that has a little more setup. Our 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? We’re calculating the remaining work.

  • Then: What ...

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