summaryrefslogtreecommitdiffstats
path: root/test/app_test.rb
diff options
context:
space:
mode:
authorZack Hobson2013-12-09 17:50:03 -0800
committerZack Hobson2013-12-09 17:50:03 -0800
commit5aec7e62d93f7a6583380d1dec998f0358161484 (patch)
treee5a9e0af9dc243eb10a4849a834fd361740c4f5f /test/app_test.rb
parentb62f8c76961c9fdfc9b9fb1f21ac60d4726505b0 (diff)
downloadhcl-5aec7e62d93f7a6583380d1dec998f0358161484.tar.bz2
app: coverage game!
Diffstat (limited to 'test/app_test.rb')
-rw-r--r--test/app_test.rb21
1 files changed, 19 insertions, 2 deletions
diff --git a/test/app_test.rb b/test/app_test.rb
index 65e3982..3226534 100644
--- a/test/app_test.rb
+++ b/test/app_test.rb
@@ -30,18 +30,35 @@ class AppTest < Test::Unit::TestCase
app.process_args('show').run
end
- def test_report_generic_failure
+ def test_generic_failure
app = HCl::App.new
app.expects(:show).raises(RuntimeError)
app.expects(:exit).with(1)
app.process_args('show').run
end
- def test_report_socket_error
+ def test_socket_error
app = HCl::App.new
app.expects(:show).raises(SocketError)
app.expects(:exit).with(1)
app.process_args('show').run
end
+ def test_configure_on_auth_failure
+ app = HCl::App.new
+ configured = states('configured').starts_as(false)
+ app.expects(:show).raises(HCl::TimesheetResource::AuthFailure).when(configured.is(false))
+ app.expects(:ask).returns('xxx').times(4).when(configured.is(false))
+ app.expects(:write_config).then(configured.is(true))
+ app.expects(:show).when(configured.is(true))
+ app.process_args('show').run
+ end
+
+ def test_api_failure
+ app = HCl::App.new
+ app.expects(:show).raises(HCl::TimesheetResource::Failure)
+ app.expects(:exit).with(1)
+ app.process_args('show').run
+ end
+
end