0
나는 다음과 같은 방법이 있습니다 방식으로 제기되는 예외의 서로 다른 유형의 message expectations를 사용하는 것을 테스트 할 RSpec에 내 제한된 이해를 바탕으로해당 메소드를 테스트하여 다른 유형의 예외를 발생시키는 방법은 무엇입니까?
이def call_http_service(url, url_params)
begin
conn = create_connection(url)
resp = get_response(conn, url_params)
raise_if_http_status_error(resp)
xml_resp = parse_xml(resp)
raise_if_client_status_error(xml_resp)
return xml_resp
rescue ClientError => e
raise ClientError, "Error interacting with feed at #{url}: #{e.message}"
rescue Faraday::Error::ClientError => e
raise ClientError, "Error interacting with feed at #{url}: #{e.message}"
rescue Nokogiri::XML::SyntaxError => e
raise ClientParseError, "Error parsing response from #{url}: #{e.message}"
rescue => e
raise e
end
end
, 그것은 보인다. 그것은 당신이 그것에 접근하는 방법입니까?
it "raises ClientError when the HTTP request raises ClientError"
# stub the http request here to raise the error
expect do
subject.call_http_service 'http://example.com'
end.to raise_error(ClientError)
end
참고 :