diff options
| -rw-r--r-- | test/command_test.rb | 20 | ||||
| -rw-r--r-- | test/task_test.rb | 34 | ||||
| -rw-r--r-- | test/test_helper.rb | 2 | ||||
| -rw-r--r-- | test/utility_test.rb | 21 |
4 files changed, 63 insertions, 14 deletions
diff --git a/test/command_test.rb b/test/command_test.rb index a2b4aff..e9ce27e 100644 --- a/test/command_test.rb +++ b/test/command_test.rb @@ -19,6 +19,18 @@ class CommandTest < HCl::TestCase @settings end + def test_config + config.each_line do |config_line| + assert_match(/^(login: bob|password: \*\*\*|subdomain: bobclock)$/, config_line) + end + end + + def test_set_without_args + @settings = {'taco.time'=>'now'} + set + 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" } @@ -29,9 +41,15 @@ class CommandTest < HCl::TestCase register_uri(:get, '/daily', {:day_entries=>[], :projects=> [{ :name=>"Harvest Command Line", :code=>"hcl", :id=>"123", :client=>"zenhob", :tasks=> [{:name=>"Development", :id=>"456"} ] + },{ + :name=>"Detached", :code=>'', :id=>"456", :client=>"zenhob", + :tasks=> [{:name=>"Development", :id=>"678"} ] }]}) result = tasks - assert_equal "123 456\tzenhob - [hcl] Harvest Command Line - Development", result + assert_equal \ + "456 678\tzenhob - Detached - Development\n"+ + "123 456\tzenhob - [hcl] Harvest Command Line - Development", + result end def test_show diff --git a/test/task_test.rb b/test/task_test.rb index b224ed3..d23094f 100644 --- a/test/task_test.rb +++ b/test/task_test.rb @@ -5,18 +5,28 @@ class TaskTest < HCl::TestCase end def test_cache_tasks_hash - HCl::Task.cache_tasks_hash({ projects: [{ - name: "Click and Type", - id: 3, - client: "AFS", - tasks: [{ - name: "Security support", - id: 14, - billable: true - }] - }]}) - assert_equal 1, HCl::Task.all.size - assert_equal 'Security support', HCl::Task.all.first.name + HCl::Task.cache_tasks_hash({ projects: [ { + name: "taco tasks", + id: 3, + client: "Taco Town", + tasks: [{ + name: "frying tortilla", + id: 12, + billable: true + }] + }, { + name: "burrito tasks", + id: 5, + client: "Burritoville", + tasks: [{ + name: "wrapping", + id: 16, + billable: true + }] + } ]}) + assert_equal 2, HCl::Task.all.size + assert_equal 'wrapping', HCl::Task.all.first.name + assert_equal 'frying tortilla', HCl::Task.all.last.name end def test_add diff --git a/test/test_helper.rb b/test/test_helper.rb index d0dfeae..addb134 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -11,7 +11,7 @@ begin # source: https://travis-ci.org/zenhob/hcl minimum_coverage 80 end -rescue LoadError => e +rescue LoadError $stderr.puts 'No test coverage tools found, skipping coverage check.' end diff --git a/test/utility_test.rb b/test/utility_test.rb index adc55b6..b0fb09c 100644 --- a/test/utility_test.rb +++ b/test/utility_test.rb @@ -3,6 +3,27 @@ require 'test_helper' class UtilityTest < HCl::TestCase include HCl::Utility + def test_get_task_ids + @settings = {'task.taco'=>'123 456'} + assert_equal ['123', '456'], get_task_ids('taco', []) + end + + def test_get_ident_with_symbol + assert_equal 'taco', get_ident(%w[ +:25 @taco makin tacos ]) + end + + def test_get_ident_without_symbol + assert_equal 'burrito', get_ident(%w[ burrito +:32 makin burritos ]) + end + + def test_get_starting_time_minutes + assert_equal 0.25, get_starting_time(%w[ @taco +:15 makin tacos ]) + end + + def test_get_starting_time_decimal + assert_equal 0.25, get_starting_time(%w[ @taco +.25 makin tacos ]) + end + def test_time2float_decimal assert_equal 2.5, time2float("2.5") end |
