spec/timetrap_spec.rb in samg-timetrap-1.0.3 vs spec/timetrap_spec.rb in samg-timetrap-1.1.0
- old
+ new
@@ -186,16 +186,46 @@
$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')
+ 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
+ describe 'csv' do
+
+ it "should not export running items" do
+ invoke 'in'
+ invoke 'format --format csv'
+ $stdout.string.should == <<-EOF
+start,end,note
+"2008-10-03 12:00:00","2008-10-03 14:00:00","note"
+"2008-10-05 12:00:00","2008-10-05 14:00:00","note"
+ EOF
end
+ it "should filter events by the passed dates" do
+ invoke 'format --format csv --start 2008-10-03 --end 2008-10-03'
+ $stdout.string.should == <<-EOF
+start,end,note
+"2008-10-03 12:00:00","2008-10-03 14:00:00","note"
+ EOF
+ end
+
+ it "should not filter events by date when none are passed" do
+ invoke 'format --format csv'
+ $stdout.string.should == <<-EOF
+start,end,note
+"2008-10-03 12:00:00","2008-10-03 14:00:00","note"
+"2008-10-05 12:00:00","2008-10-05 14:00:00","note"
+ EOF
+ end
+ end
+
+ describe 'ical' do
+
it "should not export running items" do
invoke 'in'
invoke 'format --format ical'
$stdout.string.scan(/BEGIN:VEVENT/).should have(2).item
end
@@ -292,30 +322,39 @@
end.should change(Timetrap::Entry, :count).by(-1)
end
end
describe "list" do
- before do
- Time.stub!(:now).and_return Time.parse("Oct 5 18:00:00 -0700 2008")
- create_entry( :sheet => 'A Longly Named Sheet 2', :start => '2008-10-03 12:00:00',
- :end => '2008-10-03 14:00:00')
- create_entry( :sheet => 'A Longly Named Sheet 2', :start => '2008-10-03 12:00:00',
- :end => '2008-10-03 14:00:00')
- create_entry( :sheet => 'A Longly Named Sheet 2', :start => '2008-10-05 12:00:00',
- :end => '2008-10-05 14:00:00')
- create_entry( :sheet => 'A Longly Named Sheet 2', :start => '2008-10-05 14:00:00',
- :end => nil)
- create_entry( :sheet => 'Sheet 1', :start => '2008-10-03 16:00:00',
- :end => '2008-10-03 18:00:00')
- Timetrap.current_sheet = 'A Longly Named Sheet 2'
+ describe "with no sheets defined" do
+ it "should say that there are no sheets" do
+ invoke 'list'
+ $stdout.string.chomp.should == 'No sheets found'
+ end
end
- it "should list available timesheets" do
- invoke 'list'
- $stdout.string.should == <<-OUTPUT
+
+ describe "with sheets defined" do
+ before do
+ Time.stub!(:now).and_return Time.parse("Oct 5 18:00:00 -0700 2008")
+ create_entry( :sheet => 'A Longly Named Sheet 2', :start => '2008-10-03 12:00:00',
+ :end => '2008-10-03 14:00:00')
+ create_entry( :sheet => 'A Longly Named Sheet 2', :start => '2008-10-03 12:00:00',
+ :end => '2008-10-03 14:00:00')
+ create_entry( :sheet => 'A Longly Named Sheet 2', :start => '2008-10-05 12:00:00',
+ :end => '2008-10-05 14:00:00')
+ create_entry( :sheet => 'A Longly Named Sheet 2', :start => '2008-10-05 14:00:00',
+ :end => nil)
+ create_entry( :sheet => 'Sheet 1', :start => '2008-10-03 16:00:00',
+ :end => '2008-10-03 18:00:00')
+ Timetrap.current_sheet = 'A Longly Named Sheet 2'
+ end
+ it "should list available timesheets" do
+ invoke 'list'
+ $stdout.string.should == <<-OUTPUT
Timesheet Running Today Total Time
*A Longly Named Sheet 2 4:00:00 6:00:00 10:00:00
Sheet 1 0:00:00 0:00:00 2:00:00
- OUTPUT
+ OUTPUT
+ end
end
end
describe "now" do
before do