diff options
| author | Zack Hobson | 2014-04-21 16:19:18 -0700 |
|---|---|---|
| committer | Zack Hobson | 2014-04-21 16:19:18 -0700 |
| commit | 4c1d1dfec55c8c7240b5a6325174667461ba6099 (patch) | |
| tree | 2f293cc0af946d1a621080589cfec5207911ec97 /test | |
| parent | 065d0823f2b7d4c766b281c2c828bdf87bc10a40 (diff) | |
| download | hcl-4c1d1dfec55c8c7240b5a6325174667461ba6099.tar.bz2 | |
net_test: cover failure cases
Diffstat (limited to 'test')
| -rw-r--r-- | test/net_test.rb | 20 | ||||
| -rw-r--r-- | test/test_helper.rb | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/test/net_test.rb b/test/net_test.rb index 8d967e5..705ca73 100644 --- a/test/net_test.rb +++ b/test/net_test.rb @@ -8,6 +8,26 @@ class NetTest < HCl::TestCase assert_equal 'bobclock', http.subdomain end + def test_redirect_failure + register_status(:get, "/taco", 302) + assert_raises(HCl::HarvestMiddleware::Failure) { http.get('/taco') } + end + + def test_auth_failure + register_status(:get, "/burrito", 403) + assert_raises(HCl::HarvestMiddleware::AuthFailure) { http.get('/burrito') } + end + + def test_throttle_failure + register_status(:get, "/sushi", 503) + assert_raises(HCl::HarvestMiddleware::ThrottleFailure) { http.get('/sushi') } + end + + def test_generic_failure + register_status(:get, "/kimchee", 500) + assert_raises(HCl::HarvestMiddleware::Failure) { http.get('/kimchee') } + end + def test_http_deep_unescape register_uri(:get, "/foo", { status:'gotten & got!', diff --git a/test/test_helper.rb b/test/test_helper.rb index addb134..c87c1db 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -43,6 +43,10 @@ class HCl::TestCase < MiniTest::Test @stubs.send(method, path) { [200, {}, Yajl::Encoder.encode(data)] } end + def register_status method, path, status_code + @stubs.send(method, path) { [status_code.to_i, {}, ''] } + end + def teardown @stubs.verify_stubbed_calls end |
