Using the Time Data
Learn to add some more tests for time data, make the tests pass, and refactor the code.
The Project
test
With the task tests passing, it’s time to switch our attention back to the Project
test. It would be best if we made a slight tweak to our project_spec
setup so that we have tasks that are in and out of the three-week velocity window:
rsync -avr --progress /usercode/* /usr/local/educative/gatherer --exclude Gemfile --exclude Gemfile.lock --exclude execute_.sh --exclude execute.sh cd /usr/local/educative/gatherer clear bundle exec rspec
Setting up project_spec.rb file
Here we add one more completed task, and we use the ability to pass a completed date to differentiate the two. Note that the total size is now 10
instead of 7
and the total-size test needs to be changed accordingly.
Math computations
Now the calculations we need for determining the projected project status are straightforward math based on this data:
Press + to interact
it "knows its velocity" doexpect(project.completed_velocity).to eq(3)endit "knows its rate" doexpect(project.current_rate).to eq(1.0 / 7) # <label id="code.algebra" />endit "knows its projected days remaining" doexpect(project.projected_days_remaining).to eq(35) # <label id="code.number" />endit "knows if it is not on schedule" doproject.due_date = 1.week.from_nowexpect(project).not_to be_on_scheduleendit "knows if it is on schedule" doproject.due_date = 6.months.from_nowexpect(project).to be_on_scheduleend
Note: After adding the code to the SPA widget, we can rerun the code using the ...