spec/timetrap_spec.rb in samg-timetrap-0.0.3 vs spec/timetrap_spec.rb in samg-timetrap-0.0.4

- old
+ new

@@ -27,15 +27,37 @@ describe 'alter' do before do Timetrap.start "running entry", nil end + it "should alter the description of the active period" do Timetrap.active_entry.note.should == 'running entry' invoke 'alter new description' Timetrap.active_entry.note.should == 'new description' end + + it "should alter the start time of the active period" do + invoke 'alter --start "yesterday 10am"' + Timetrap.active_entry.start.should == Chronic.parse("yesterday 10am") + Timetrap.active_entry.note.should == 'running entry' + end + + it "should alter the end time of the active period" do + entry = Timetrap.active_entry + invoke 'alter --end "yesterday 10am"' + entry.refresh.end.should == Chronic.parse("yesterday 10am") + entry.refresh.note.should == 'running entry' + end + + it "should alter a non running entry based on id" do + not_running = Timetrap.active_entry + Timetrap.stop + Timetrap.start "another entry", nil + invoke "alter --id #{not_running.id} a new description" + not_running.refresh.note.should == 'a new description' + end end describe "backend" do it "should open an sqlite console to the db" do Timetrap::CLI.should_receive(:exec).with("sqlite3 #{DB_NAME}") @@ -72,10 +94,23 @@ 18:00:00 - 2:00:00 entry 4 4:00:00 --------------------------------------------------------- Total 8:00:00 OUTPUT + + @desired_output_with_ids = <<-OUTPUT +Timesheet: SpecSheet + Id Day Start End Duration Notes + 3 Fri Oct 03, 2008 12:00:00 - 14:00:00 2:00:00 entry 1 + 2 16:00:00 - 18:00:00 2:00:00 entry 2 + 4:00:00 + 4 Sun Oct 05, 2008 16:00:00 - 18:00:00 2:00:00 entry 3 + 5 18:00:00 - 2:00:00 entry 4 + 4:00:00 + --------------------------------------------------------- + Total 8:00:00 + OUTPUT end it "should display the current timesheet" do Timetrap.current_sheet = 'SpecSheet' invoke 'display' @@ -91,10 +126,15 @@ it "should display a non current timesheet based on a partial name match" do Timetrap.current_sheet = 'another' invoke 'display S' $stdout.string.should == @desired_output end + + it "should display a timesheet with ids" do + invoke 'display S --ids' + $stdout.string.should == @desired_output_with_ids + end end describe "format" do it "should export a sheet to a csv format" do pending @@ -248,9 +288,15 @@ it "should switch to a new timesheet" do invoke 'switch sheet 1' Timetrap.current_sheet.should == 'sheet 1' invoke 'switch sheet 2' Timetrap.current_sheet.should == 'sheet 2' + end + + it "should not switch to an blank timesheet" do + invoke 'switch sheet 1' + invoke 'switch' + Timetrap.current_sheet.should == 'sheet 1' end end end end