From 63a5d98a7c921289e9b43f4b54c03614427f7eda Mon Sep 17 00:00:00 2001 From: Jose Ivan Vargas Date: Tue, 2 May 2017 11:16:59 -0500 Subject: Added specs --- spec/support/prometheus_helpers.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec/support') diff --git a/spec/support/prometheus_helpers.rb b/spec/support/prometheus_helpers.rb index cc79b11616a..625a40e1154 100644 --- a/spec/support/prometheus_helpers.rb +++ b/spec/support/prometheus_helpers.rb @@ -33,6 +33,16 @@ module PrometheusHelpers }) end + def stub_prometheus_request_with_socket_exception(url) + WebMock.stub_request(:get, url) + .to_raise(SocketError) + end + + def stub_prometheus_request_with_ssl_exception(url) + WebMock.stub_request(:get, url) + .to_raise(OpenSSL::SSL::SSLError) + end + def stub_all_prometheus_requests(environment_slug, body: nil, status: 200) stub_prometheus_request( prometheus_query_url(prometheus_memory_query(environment_slug)), -- cgit v1.2.1 From 64e811957795293b647bda7aef23ffbd92082614 Mon Sep 17 00:00:00 2001 From: Jose Ivan Vargas Date: Tue, 2 May 2017 16:53:49 -0500 Subject: Improved code styling and added a HTTParty rescue block --- spec/support/prometheus_helpers.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'spec/support') diff --git a/spec/support/prometheus_helpers.rb b/spec/support/prometheus_helpers.rb index 625a40e1154..a204365431b 100644 --- a/spec/support/prometheus_helpers.rb +++ b/spec/support/prometheus_helpers.rb @@ -33,14 +33,8 @@ module PrometheusHelpers }) end - def stub_prometheus_request_with_socket_exception(url) - WebMock.stub_request(:get, url) - .to_raise(SocketError) - end - - def stub_prometheus_request_with_ssl_exception(url) - WebMock.stub_request(:get, url) - .to_raise(OpenSSL::SSL::SSLError) + def stub_prometheus_request_with_exception(url, exception_type) + WebMock.stub_request(:get, url).to_raise(exception_type) end def stub_all_prometheus_requests(environment_slug, body: nil, status: 200) -- cgit v1.2.1