diff options
| author | Zack Hobson | 2013-11-21 12:02:47 -0800 | 
|---|---|---|
| committer | Zack Hobson | 2013-11-21 12:06:52 -0800 | 
| commit | 125133158e4d021526638789848b238ecd268f49 (patch) | |
| tree | 404e2c6db5e8f85d09943e22ed3f2fd7908faf5b /test/command_test.rb | |
| parent | 86ff02c8380fc50cfa7e0d4e6d0cfd7be56fb633 (diff) | |
| download | hcl-125133158e4d021526638789848b238ecd268f49.tar.bz2 | |
Test and dev improvements
* removed dependency on shoulda
* added bundler support for dev/testing
* test coverage reporting
* added some command tests
Diffstat (limited to 'test/command_test.rb')
| -rw-r--r-- | test/command_test.rb | 70 | 
1 files changed, 70 insertions, 0 deletions
| diff --git a/test/command_test.rb b/test/command_test.rb new file mode 100644 index 0000000..0b3b5c1 --- /dev/null +++ b/test/command_test.rb @@ -0,0 +1,70 @@ +require 'test_helper' +class CommandTest < Test::Unit::TestCase +  include HCl::Commands +  include HCl::Utility + +  def setup +    @settings = {} +  end + +  # the current_time utility method needs to be deterministic +  def current_time +    'high noon' +  end + +  # stub settings helpers +  def write_settings; end +  def read_settings +    @settings +  end + +  def test_tasks +    HCl::Task.expects(:all).returns([HCl::Task.new( +      id:123, +      name: 'Dev', +      project: HCl::Project.new(id:456, name:'App', client:'Bob', code:'b') +    )]) +    result = tasks +    assert_equal "456 123\tBob - [b] App - Dev", result +  end + +  def test_show +    HCl::DayEntry.expects(:all).returns([HCl::DayEntry.new({ +      hours:'2.06', +      notes: 'hi world', +      project: 'App' +    })]) +    result = show +    assert_equal \ +      "\t2:03\tApp: hi world\n\t-------------\n\t2:03\ttotal (as of high noon)\n", +      result +  end + +  def test_aliases +    HCl::Task.expects(:all).returns([HCl::Task.new( +      id:123, +      name: 'Dev', +      project: HCl::Project.new(id:456, name:'App', client:'Bob', code:'b') +    )]) +    result = send :alias, *%w[ hcl 456 123 ] +    assert_equal '456 123', @settings['task.hcl'] + +    result = aliases +    assert_equal ["@hcl"], result + +    result = unalias 'hcl' +    assert !@settings.key?('task.hcl'), 'hcl alias is no longer defined' +  end + +  def test_start +    task = HCl::Task.new( +      id:123, +      name: 'Dev', +      project: HCl::Project.new(id:456, name:'App', client:'Bob', code:'b') +    ) +    HCl::Task.expects(:find).with('456','123').returns(task) +    task.expects(:start).with(starting_time:nil, note:'do stuff') +    start *%w[ 456 123 do stuff ] +  end + +end | 
