diff options
| author | Zack Hobson | 2013-12-20 11:17:35 -0800 | 
|---|---|---|
| committer | Zack Hobson | 2013-12-20 11:17:35 -0800 | 
| commit | fd2bb13174bb2605fac838c666597f6f223e81dc (patch) | |
| tree | bdf8032e55d2ddd4ffafea60bbfd547942d723ac | |
| parent | 33e5f975dc7690642097267ef926ff8ad06c86b7 (diff) | |
| download | hcl-fd2bb13174bb2605fac838c666597f6f223e81dc.tar.bz2 | |
log: check for a running timer.
| -rw-r--r-- | CHANGELOG | 1 | ||||
| -rw-r--r-- | lib/hcl/commands.rb | 1 | ||||
| -rw-r--r-- | lib/hcl/utility.rb | 4 | ||||
| -rw-r--r-- | test/command_test.rb | 5 | 
4 files changed, 9 insertions, 2 deletions
| @@ -3,6 +3,7 @@  == next  * MacOS X: store password in default keychain +* abort log command when a timer is running  == v0.4.8 2013-11-30 diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb index da3b1f0..a725ad4 100644 --- a/lib/hcl/commands.rb +++ b/lib/hcl/commands.rb @@ -88,6 +88,7 @@ module HCl      end      def log *args +      fail "There is already a timer running." if DayEntry.with_timer        start *args        stop      end diff --git a/lib/hcl/utility.rb b/lib/hcl/utility.rb index 72b4842..fd01901 100644 --- a/lib/hcl/utility.rb +++ b/lib/hcl/utility.rb @@ -1,8 +1,8 @@  module HCl    class CommandError < StandardError; end    module Utility -    def fail message -      raise CommandError, message +    def fail *message +      raise CommandError, message.join(' ')      end      def get_task_ids ident, args diff --git a/test/command_test.rb b/test/command_test.rb index b554bfd..dd6f440 100644 --- a/test/command_test.rb +++ b/test/command_test.rb @@ -18,6 +18,11 @@ class CommandTest < HCl::TestCase      @settings    end +  def test_log_failure +    HCl::DayEntry.expects(:with_timer).returns(stub) +    assert_raises(HCl::CommandError) { log "stuff" } +  end +    def test_tasks      HCl::Task.expects(:all).returns([HCl::Task.new(        id:123, | 
