summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorZack Hobson2013-11-22 10:09:27 -0800
committerZack Hobson2013-11-22 10:09:27 -0800
commit684ae1d2d0160a36c704dbc87686d1524647aeff (patch)
treea82a66ffe01dfebc799b735d31f6115ba4379d08 /test
parentf99f6b6805a801b2d4bd37d357d0e2d9191c8a5a (diff)
downloadhcl-684ae1d2d0160a36c704dbc87686d1524647aeff.tar.bz2
app: retry on throttle
Diffstat (limited to 'test')
-rw-r--r--test/app_test.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/app_test.rb b/test/app_test.rb
index cbee636..28acba9 100644
--- a/test/app_test.rb
+++ b/test/app_test.rb
@@ -7,11 +7,22 @@ class AppTest < Test::Unit::TestCase
end
def test_command_show
- HCl::DayEntry.expects(:all).returns([HCl::DayEntry.new({
+ HCl::DayEntry.expects(:all).returns [HCl::DayEntry.new(
hours:'2.06',
notes: 'hi world',
project: 'App'
- })])
+ )]
HCl::App.command 'show'
end
+
+ def test_command_retry_on_throttle
+ app = HCl::App.new
+ throttled = states('throttled').starts_as(false)
+ app.expects(:show).
+ raises(HCl::TimesheetResource::ThrottleFailure, stub(headers:{'Retry-After' => 42})).
+ then(throttled.is(true))
+ app.expects(:sleep).with(47).when(throttled.is(true))
+ app.expects(:show).when(throttled.is(true))
+ app.process_args('show').run
+ end
end