diff options
| author | Zack Hobson | 2013-11-21 12:59:36 -0800 | 
|---|---|---|
| committer | Zack Hobson | 2013-11-21 12:59:36 -0800 | 
| commit | 6c903fd0c4ef000c01ff7a3ece0cf9da27b3530c (patch) | |
| tree | 79fdd29f3e43fa648f75b21af599fcf5941fb5ee | |
| parent | ba28437f7a56e0f817fe1b51e46e756b7f6cc1f9 (diff) | |
| download | hcl-6c903fd0c4ef000c01ff7a3ece0cf9da27b3530c.tar.bz2 | |
coverage tests for app, command, task.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | lib/hcl/commands.rb | 6 | ||||
| -rw-r--r-- | test/app_test.rb | 9 | ||||
| -rw-r--r-- | test/command_test.rb | 29 | ||||
| -rw-r--r-- | test/task_test.rb | 26 | 
5 files changed, 68 insertions, 3 deletions
| @@ -7,3 +7,4 @@ doc  .rvmrc.*  *.gem  coverage +test/dot_hcl diff --git a/lib/hcl/commands.rb b/lib/hcl/commands.rb index c245710..d1861de 100644 --- a/lib/hcl/commands.rb +++ b/lib/hcl/commands.rb @@ -35,7 +35,7 @@ module HCl        entry = DayEntry.with_timer || DayEntry.last        if entry          if entry.cancel -          puts "Deleted entry #{entry}." +          "Deleted entry #{entry}."          else            puts "Failed to delete #{entry}!"            exit 1 @@ -100,7 +100,7 @@ module HCl        if entry          entry.append_note(args.join(' ')) if args.any?          entry.toggle -        puts "Stopped #{entry} (at #{current_time})" +        "Stopped #{entry} (at #{current_time})"        else          puts "No running timers found."          exit 1 @@ -112,7 +112,7 @@ module HCl        entry = DayEntry.with_timer        if entry          entry.append_note message -        puts "Added note to #{entry}." +        "Added note to #{entry}."        else          puts "No running timers found."          exit 1 diff --git a/test/app_test.rb b/test/app_test.rb index 0b4c90b..cbee636 100644 --- a/test/app_test.rb +++ b/test/app_test.rb @@ -5,4 +5,13 @@ class AppTest < Test::Unit::TestCase      app = HCl::App.new      assert HCl::Commands.instance_methods.all? { |c| app.command? c  }, 'all methods are commands'    end + +  def test_command_show +    HCl::DayEntry.expects(:all).returns([HCl::DayEntry.new({ +      hours:'2.06', +      notes: 'hi world', +      project: 'App' +    })]) +    HCl::App.command 'show' +  end  end diff --git a/test/command_test.rb b/test/command_test.rb index 0b3b5c1..5a2e003 100644 --- a/test/command_test.rb +++ b/test/command_test.rb @@ -67,4 +67,33 @@ class CommandTest < Test::Unit::TestCase      start *%w[ 456 123 do stuff ]    end +  def test_stop +    entry = stub +    HCl::DayEntry.expects(:with_timer).returns(entry) +    entry.expects(:append_note).with('all done') +    entry.expects(:toggle) +    stop 'all done' +  end + +  def test_resume +    entry = stub +    HCl::DayEntry.expects(:last).returns(entry) +    entry.expects(:toggle) +    resume +  end + +  def test_cancel +    entry = stub +    HCl::DayEntry.expects(:with_timer).returns(entry) +    entry.expects(:cancel).returns(true) +    cancel +  end + +  def test_note +    entry = stub +    HCl::DayEntry.expects(:with_timer).returns(entry) +    entry.expects(:append_note).with('hi world') +    note 'hi world' +  end +  end diff --git a/test/task_test.rb b/test/task_test.rb new file mode 100644 index 0000000..e69fcf9 --- /dev/null +++ b/test/task_test.rb @@ -0,0 +1,26 @@ + +class Task < Test::Unit::TestCase +  def test_cache_tasks +    HCl::Task.cache_tasks(REXML::Document.new(<<-EOD)) +<daily> +  <projects> +    <project> +      <name>Click and Type</name> +      <code></code> +      <id type="integer">3</id> +      <client>AFS</client> +      <tasks> +        <task> +          <name>Security support</name> +          <id type="integer">14</id> +          <billable type="boolean">true</billable> +        </task> +      </tasks> +    </project> +  </projects> +</daily> +    EOD +    assert_equal 1, HCl::Task.all.size +    assert_equal 'Security support', HCl::Task.all.first.name +  end +end | 
