...

/

Using the Time Data

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" do
expect(project.completed_velocity).to eq(3)
end
it "knows its rate" do
expect(project.current_rate).to eq(1.0 / 7) # <label id="code.algebra" />
end
it "knows its projected days remaining" do
expect(project.projected_days_remaining).to eq(35) # <label id="code.number" />
end
it "knows if it is not on schedule" do
project.due_date = 1.week.from_now
expect(project).not_to be_on_schedule
end
it "knows if it is on schedule" do
project.due_date = 6.months.from_now
expect(project).to be_on_schedule
end

Note: After adding the code to the SPA widget, we can rerun the code using the ...