spec/timetrap_spec.rb in samg-timetrap-1.0.1 vs spec/timetrap_spec.rb in samg-timetrap-1.0.3
- old
+ new
@@ -23,39 +23,55 @@
def invoke command
Timetrap::CLI.parse command
Timetrap::CLI.invoke
end
- describe 'alter' do
+ describe 'archive' do
before do
+ 3.times do |i|
+ create_entry
+ end
+ end
+
+ it "should put the entries in a hidden sheet" do
+ $stdin.string = "yes\n"
+ invoke 'archive'
+ Timetrap::Entry.each do |e|
+ e.sheet.should == '_default'
+ end
+ end
+ end
+
+ describe 'edit' do
+ before do
Timetrap.start "running entry", nil
end
- it "should alter the description of the active period" do
+ it "should edit the description of the active period" do
Timetrap.active_entry.note.should == 'running entry'
- invoke 'alter new description'
+ invoke 'edit 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"'
+ it "should edit the start time of the active period" do
+ invoke 'edit --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
+ it "should edit the end time of the active period" do
entry = Timetrap.active_entry
- invoke 'alter --end "yesterday 10am"'
+ invoke 'edit --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
+ it "should edit 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"
+ invoke "edit --id #{not_running.id} a new description"
not_running.refresh.note.should == 'a new description'
end
end
describe "backend" do
@@ -159,16 +175,30 @@
it "should display all timesheets" do
Timetrap.current_sheet = 'another'
invoke 'display all'
$stdout.string.should == @desired_output_for_all
end
+
+ it "should not display archived for all timesheets" do
+ $stdin.string = "yes\n"
+ invoke 'archive SpecSheet'
+ $stdout.string = ''
+ invoke 'display all'
+ $stdout.string.should_not =~ /_SpecSheet/
+ end
end
describe "format" do
describe 'ical' do
before do
create_entry(:start => '2008-10-03 12:00:00', :end => '2008-10-03 14:00:00')
create_entry(:start => '2008-10-05 12:00:00', :end => '2008-10-05 14:00:00')
+ end
+
+ it "should not export running items" do
+ invoke 'in'
+ invoke 'format --format ical'
+ $stdout.string.scan(/BEGIN:VEVENT/).should have(2).item
end
it "should filter events by the passed dates" do
invoke 'format --format ical --start 2008-10-03 --end 2008-10-03'
$stdout.string.scan(/BEGIN:VEVENT/).should have(1).item