test/web_test.rb in vault-tools-0.3.10 vs test/web_test.rb in vault-tools-0.3.11

- old
+ new

@@ -9,10 +9,12 @@ end # Always reload the web class to eliminate test leakage def setup super + set_env('APP_NAME', 'test-app') + set_env('APP_DEPLOY', 'testing') reload_web! end def test_http_basic_auth app.set :basic_password, 'password' @@ -40,39 +42,39 @@ # An `http_200` and an `http_2xx` log metric is written for successful # requests. def test_head_status_check head '/' - assert_match(/count#http_200=1/, Scrolls.stream.string) - assert_match(/count#http_2xx=1/, Scrolls.stream.string) + assert_equal '1', logged_data['count#test-app.http.200'] + assert_equal '1', logged_data['count#test-app.http.2xx'] assert_equal(200, last_response.status) end # A GET /health request logs success metrics and returns 'OK' in the # response body. def test_get_health_check get '/health' - assert_match(/count#http_200=1/, Scrolls.stream.string) - assert_match(/count#http_2xx=1/, Scrolls.stream.string) + assert_equal '1', logged_data['count#test-app.http.200'] + assert_equal '1', logged_data['count#test-app.http.2xx'] assert_equal(200, last_response.status) assert_equal('OK', last_response.body) end # An `http_404` and an `http_4xx` log metric is written when a path doesn't # match a known resource. def test_head_with_unknown_endpoint head '/unknown' - assert_match(/count#http_404=1/, Scrolls.stream.string) - assert_match(/count#http_4xx=1/, Scrolls.stream.string) + assert_equal '1', logged_data['count#test-app.http.404'] + assert_equal '1', logged_data['count#test-app.http.4xx'] assert_equal(404, last_response.status) end # An internal server error causes a `web-50` log entry to be written. A # traceback is also written to the response body to ease debugging. def test_error_logs_500 get '/boom' - assert_match(/count#http_500=1/, Scrolls.stream.string) - assert_match(/count#http_5xx=1/, Scrolls.stream.string) + assert_equal '1', logged_data['count#test-app.http.500'] + assert_equal '1', logged_data['count#test-app.http.5xx'] assert_match(/^RuntimeError: An expected error occurred.$/m, last_response.body) assert_equal(500, last_response.status) end