diff options
| author | Zack Hobson | 2014-01-26 10:07:28 -0800 | 
|---|---|---|
| committer | Zack Hobson | 2014-01-26 10:11:32 -0800 | 
| commit | 300ff2b3e1ccd190f361f47ef2eb640d7e141073 (patch) | |
| tree | 79590120cf1b1689a0572e0d68be2a9a06008806 | |
| parent | d95054ddf4fd4d2152d213d7a1391831f9540d0b (diff) | |
| download | hcl-300ff2b3e1ccd190f361f47ef2eb640d7e141073.tar.bz2 | |
confirm timer cancel, closes #47
| -rw-r--r-- | lib/hcl/commands.rb | 3 | ||||
| -rw-r--r-- | test/command_test.rb | 8 | 
2 files changed, 11 insertions, 0 deletions
| diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb index c753fbf..9bad615 100644 --- a/lib/hcl/commands.rb +++ b/lib/hcl/commands.rb @@ -45,6 +45,9 @@ module HCl      def cancel        entry = DayEntry.with_timer(http) || DayEntry.last(http)        if entry +        confirmed = /^y/.match(ask("#{entry}\nDelete this entry? (y/n): ").downcase) +        return unless confirmed +          if entry.cancel http            "Deleted entry #{entry}."          else diff --git a/test/command_test.rb b/test/command_test.rb index 2e2812f..e3f9806 100644 --- a/test/command_test.rb +++ b/test/command_test.rb @@ -100,6 +100,14 @@ class CommandTest < HCl::TestCase      entry = stub      HCl::DayEntry.expects(:with_timer).with(http).returns(entry)      entry.expects(:cancel).with(http).returns(true) +    expects(:ask).returns('y') +    cancel +  end + +  def test_cancel_no +    entry = stub +    HCl::DayEntry.expects(:with_timer).with(http).returns(entry) +    expects(:ask).returns('n')      cancel    end | 
