summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTeddy Wing2018-01-27 00:31:57 +0100
committerTeddy Wing2018-01-31 20:47:10 +0100
commit873325ebce6d0451263d115a8f02f40e0a6fbd40 (patch)
tree861fada27872332705c59c41b8cf045f86bd57fe /test
parentcea2bbe0d1b2c9629d7fab397093856580a9e099 (diff)
downloadhcl-log-for-past-days--squashed.tar.bz2
Add date argument to `log` commandlog-for-past-days--squashed
Adds an optional date argument to the `log` command that can be specified just before the task alias. Some examples from @skoppelmanCC: hcl log yesterday @documentation +2 Ran spellcheck hcl log 3 days ago @wireframes +3.5 hcl log last friday @admin +1 filed timesheets Commands#log: Copy over the contents of `Commands#start` and replace `task.start` with `task.add`. This allows us to log the time without actually starting a timer (and thus having to subsequently stop that timer). command_test.rb(#test_start): Update expected method call arguments with `spent_at`. Now that we're passing in `spent_at`, the expected arguments should include it. command_test.rb(#test_log_failure): Delete this test because I've rewritten the `Commands#log` method to no longer use timers. utility_test.rb: Add tests for `#get_date` Fixes #83.
Diffstat (limited to 'test')
-rw-r--r--test/command_test.rb5
-rw-r--r--test/utility_test.rb8
2 files changed, 8 insertions, 5 deletions
diff --git a/test/command_test.rb b/test/command_test.rb
index 8536286..94ff673 100644
--- a/test/command_test.rb
+++ b/test/command_test.rb
@@ -31,11 +31,6 @@ class CommandTest < HCl::TestCase
assert_equal "taco.time: now\n", standard_output
end
- def test_log_failure
- HCl::DayEntry.expects(:with_timer).returns(stub)
- assert_raises(HCl::CommandError) { log "stuff" }
- end
-
def test_tasks
FileUtils.rm_rf ENV['HCL_DIR']+"/cache"
register_uri(:get, '/daily', {:day_entries=>[], :projects=> [{
diff --git a/test/utility_test.rb b/test/utility_test.rb
index b0fb09c..222d129 100644
--- a/test/utility_test.rb
+++ b/test/utility_test.rb
@@ -24,6 +24,14 @@ class UtilityTest < HCl::TestCase
assert_equal 0.25, get_starting_time(%w[ @taco +.25 makin tacos ])
end
+ def test_get_date_without_ident
+ assert_nil get_date(%w[ yesterday +2 no task ])
+ end
+
+ def test_get_date_with_ident
+ assert_equal Chronic.parse('2018-01-15'), get_date(%w[ january 15 2018 @taco +.30 makin tacos ])
+ end
+
def test_time2float_decimal
assert_equal 2.5, time2float("2.5")
end