From 24bb1cc3fea3e75aedcc64cdc30bb73089a7c157 Mon Sep 17 00:00:00 2001 From: Zack Hobson Date: Sun, 22 Dec 2013 02:01:37 -0800 Subject: coverage game! --- test/day_entry_test.rb | 18 ++++++++++++++++++ test/task_test.rb | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/day_entry_test.rb b/test/day_entry_test.rb index 5b390c3..581b22b 100644 --- a/test/day_entry_test.rb +++ b/test/day_entry_test.rb @@ -1,6 +1,24 @@ require 'test_helper' class DayEntryTest < HCl::TestCase + def test_cancel_success + entry = HCl::DayEntry.new(id:123) + HCl::DayEntry.expects(:delete) + assert entry.cancel + end + + def test_cancel_failure + entry = HCl::DayEntry.new(id:123) + HCl::DayEntry.expects(:delete).raises(HCl::TimesheetResource::Failure) + assert !entry.cancel + end + + def test_to_s + entry = HCl::DayEntry.new \ + hours: '1.2', client: 'Taco Town', project:'Pizza Taco', task:'Preparation' + assert_equal "Taco Town - Pizza Taco - Preparation (1:12)", entry.to_s + end + def test_from_xml entries = HCl::DayEntry.from_xml(<<-EOD) diff --git a/test/task_test.rb b/test/task_test.rb index e313f73..f5c30b8 100644 --- a/test/task_test.rb +++ b/test/task_test.rb @@ -1,5 +1,37 @@ -class Task < HCl::TestCase +class TaskTest < HCl::TestCase + DAILY_ENTRY = %{ + Wed, 18 Oct 2006 + + + 195168 + Iridesco + Harvest + Backend Programming + 2.06 + Test api support + + Wed, 18 Oct 2006 09:53:06 -0000 + + Wed, 18 Oct 2006 09:53:06 -0000 + + + } + + def test_add_task + task = HCl::Task.new(id:456, project:HCl::Project.new(id:123)) + Date.expects(:today).returns('now') + HCl::Task.expects(:post).with('daily/add', <<-EOT).returns(DAILY_ENTRY) + + hi world + 0.5 + 123 + 456 + now + + EOT + task.add note:'hi world', starting_time:0.5 + end def test_cache_file assert_equal "#{HCl::App::HCL_DIR}/cache/tasks.yml", HCl::Task.cache_file end -- cgit v1.2.3