spec/unit/domain/project_spec.rb in trajectory-0.1.1 vs spec/unit/domain/project_spec.rb in trajectory-0.1.2

- old
+ new

@@ -34,10 +34,19 @@ DataStore.stub(:stories_for_project).and_return(stories) Project.new.total_points.should == 20 end + it 'can evaluate remaining iterations until project completion based on the last non nul velocity' do + stories = Stories.new(double(:story, :points => 2, :completed? => false), + double(:story, :points => 10, :completed? => false), + double(:story, :points => 8, :completed? => true)) + DataStore.stub(:stories_for_project).and_return(stories) + + Project.new(:estimated_velocity => 2).remaining_iterations.should == 6 + end + it 'can evaluate remaining points' do stories = Stories.new(double(:story, :points => 2, :completed? => false), double(:story, :points => 10, :completed? => false), double(:story, :points => 8, :completed? => true)) DataStore.stub(:stories_for_project).and_return(stories) @@ -106,10 +115,31 @@ DataStore.stub(:stories_for_project).and_return(stories) Project.new.accepted_points.should == 19 end + it 'can retrieve the last non null velocity in its history' do + Project.new(:historic_velocity => [20, 0, 2, 3, 0, 0, 0]).last_non_null_velocity.should == 3 + Project.new(:historic_velocity => [0, 0, 20, 0, 2, 3, 0, 0, 0]).last_non_null_velocity.should == 3 + Project.new(:historic_velocity => [0, 0, 20, 0, 2, 3]).last_non_null_velocity.should == 3 + end + + it 'raises an error when trying to get last non null velocity of a project that not have yet started' do + project = Project.new + project.stub(:has_started?).and_return(false) + + expect do + project.last_non_null_velocity + end.to raise_error(VelocityAlwaysEqualToZero) + end + + it 'can tell if a project has started based on historic velocity' do + Project.new(:historic_velocity => [0, 0, 20, 0, 2, 3]).should have_started + Project.new(:historic_velocity => [0, 0, 0, 0]).should_not have_started + Project.new(:historic_velocity => []).should_not have_started + end + it 'delegates fetching of iterations of a project to the data store' do DataStore.should_receive(:iterations_for_project).with(project) project.iterations end @@ -142,9 +172,18 @@ project.users_collection = users users.should_receive(:find_by_id).with(1234) project.find_user_by_id(1234) + end + + it 'can get one of its iteration by id' do + iterations = double + + project.iterations_collection = iterations + iterations.should_receive(:find_by_id).with(1234) + + project.find_iteration_by_id(1234) end context 'when estimated velocity is zero' do it 'cannot estimate remaining days until the project end' do expect do