diff --git a/bin/punch b/bin/punch index 259515e..c80ec04 100755 --- a/bin/punch +++ b/bin/punch @@ -99,7 +99,7 @@ commands = { puts "Project required" end end, - 'list' => lambda { |project| puts Punch.list(project).to_yaml }, + 'list' => lambda { |project| puts Punch.list(project, OPTIONS).to_yaml }, } if command_code = commands[command] diff --git a/spec/punch_command_spec.rb b/spec/punch_command_spec.rb index 09c6e18..3b41216 100644 --- a/spec/punch_command_spec.rb +++ b/spec/punch_command_spec.rb @@ -531,12 +531,12 @@ def run_command(*args) end it 'should get the data for the requested project' do - Punch.expects(:list).with(@project) + Punch.expects(:list).with(@project, anything) run_command('list', @project) end it 'should get the data for all projects if none given' do - Punch.expects(:list).with(nil) + Punch.expects(:list).with(nil, anything) run_command('list') end @@ -547,6 +547,36 @@ def run_command(*args) run_command('list') end + describe 'when options specified' do + it "should pass on an 'after' time option given by --after" do + time_option = '2008-08-26 09:47' + time = Time.local(2008, 8, 26, 9, 47) + Punch.expects(:list).with(@project, has_entry(:after => time)) + run_command('list', @project, '--after', time_option) + end + + it "should pass on a 'before' time option given by --before" do + time_option = '2008-08-23 15:39' + time = Time.local(2008, 8, 23, 15, 39) + Punch.expects(:list).with(@project, has_entry(:before => time)) + run_command('list', @project, '--before', time_option) + end + + it 'should handle a time option given as a date' do + time_option = '2008-08-23' + time = Time.local(2008, 8, 23) + Punch.expects(:list).with(@project, has_entry(:before => time)) + run_command('list', @project, '--before', time_option) + end + + it 'should accept time options if no project given' do + time_option = '2008-08-26 09:47' + time = Time.local(2008, 8, 26, 9, 47) + Punch.expects(:list).with(nil, has_entry(:before => time)) + run_command('list', '--before', time_option) + end + end + it 'should not write the data' do @states['write'].become('test') Punch.expects(:write).never.when(@states['write'].is('test'))