diff options
| author | Zack Hobson | 2013-11-22 12:04:02 -0800 |
|---|---|---|
| committer | Zack Hobson | 2013-11-22 12:04:16 -0800 |
| commit | 0a7e14eb48525b291aa5715e107b981af99cbe35 (patch) | |
| tree | b0e4c094ee458537a03415aa6ddfc5d0185fca8c /test | |
| parent | 6f8f7812e896c58cec91fc682528969b58807d41 (diff) | |
| download | hcl-0a7e14eb48525b291aa5715e107b981af99cbe35.tar.bz2 | |
test coverage for timesheet resource and command edge cases
Diffstat (limited to 'test')
| -rw-r--r-- | test/command_test.rb | 14 | ||||
| -rw-r--r-- | test/test_helper.rb | 1 | ||||
| -rw-r--r-- | test/timesheet_resource_test.rb | 38 |
3 files changed, 53 insertions, 0 deletions
diff --git a/test/command_test.rb b/test/command_test.rb index 5a2e003..b425974 100644 --- a/test/command_test.rb +++ b/test/command_test.rb @@ -82,6 +82,14 @@ class CommandTest < Test::Unit::TestCase resume end + def test_resume_with_task_alias + entry = stub + expects(:get_task_ids).with('mytask',[]).returns(%w[ 456 789 ]) + HCl::DayEntry.expects(:last_by_task).with('456', '789').returns(entry) + entry.expects(:toggle) + resume 'mytask' + end + def test_cancel entry = stub HCl::DayEntry.expects(:with_timer).returns(entry) @@ -96,4 +104,10 @@ class CommandTest < Test::Unit::TestCase note 'hi world' end + def test_note_display + entry = stub(notes:"your face") + HCl::DayEntry.expects(:with_timer).returns(entry) + assert_equal "your face", note + end + end diff --git a/test/test_helper.rb b/test/test_helper.rb index 978920a..8b4f7a0 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -10,6 +10,7 @@ end require 'test/unit' require 'mocha/setup' require 'fileutils' +require 'fakeweb' # override the default hcl dir FileUtils.mkdir_p __dir__+"/dot_hcl" diff --git a/test/timesheet_resource_test.rb b/test/timesheet_resource_test.rb new file mode 100644 index 0000000..93977f9 --- /dev/null +++ b/test/timesheet_resource_test.rb @@ -0,0 +1,38 @@ +require 'test_helper' + +class TimesheetResourceTest < Test::Unit::TestCase + + def setup + FakeWeb.allow_net_connect = false + HCl::TimesheetResource.configure \ + 'login' => 'bob', + 'password' => 'secret', + 'subdomain' => 'bobclock', + 'ssl' => true + end + + def test_configure + assert_equal 'bob', HCl::TimesheetResource.login + assert_equal 'secret', HCl::TimesheetResource.password + assert_equal 'bobclock', HCl::TimesheetResource.subdomain + assert_equal true, HCl::TimesheetResource.ssl + end + + def test_http_get + FakeWeb.register_uri(:get, "https://bob:secret@bobclock.harvestapp.com/foo", :body => 'gotten!') + body = HCl::TimesheetResource.get 'foo' + assert_equal 'gotten!', body + end + + def test_http_post + FakeWeb.register_uri(:post, "https://bob:secret@bobclock.harvestapp.com/foo", :body => 'posted!') + body = HCl::TimesheetResource.post 'foo', {pizza:'taco'} + assert_equal 'posted!', body + end + + def test_http_delete + FakeWeb.register_uri(:delete, "https://bob:secret@bobclock.harvestapp.com/foo", :body => 'wiped!') + body = HCl::TimesheetResource.delete 'foo' + assert_equal 'wiped!', body + end +end |
