summaryrefslogtreecommitdiffstats
path: root/test/timesheet_resource_test.rb
diff options
context:
space:
mode:
authorZack Hobson2013-11-22 12:04:02 -0800
committerZack Hobson2013-11-22 12:04:16 -0800
commit0a7e14eb48525b291aa5715e107b981af99cbe35 (patch)
treeb0e4c094ee458537a03415aa6ddfc5d0185fca8c /test/timesheet_resource_test.rb
parent6f8f7812e896c58cec91fc682528969b58807d41 (diff)
downloadhcl-0a7e14eb48525b291aa5715e107b981af99cbe35.tar.bz2
test coverage for timesheet resource and command edge cases
Diffstat (limited to 'test/timesheet_resource_test.rb')
-rw-r--r--test/timesheet_resource_test.rb38
1 files changed, 38 insertions, 0 deletions
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