diff --git a/.rubocop.yml b/.rubocop.yml index e288766..976b554 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,12 +5,53 @@ require: - standard - standard-performance -inherit_gem: - standard: config/base.yml - AllCops: NewCops: enable TargetRubyVersion: 3.0 +Layout/ArgumentAlignment: + EnforcedStyle: with_fixed_indentation + IndentationWidth: 2 + +Layout/CaseIndentation: + EnforcedStyle: end + +Layout/EndAlignment: + EnforcedStyleAlignWith: start_of_line + +Layout/LineLength: + Max: 140 + +Layout/ParameterAlignment: + EnforcedStyle: with_fixed_indentation + IndentationWidth: 2 + +Layout/SpaceInsideHashLiteralBraces: + EnforcedStyle: no_space + +Metrics/ParameterLists: + CountKeywordArgs: false + Minitest/MultipleAssertions: Max: 5 + +Style/Alias: + EnforcedStyle: prefer_alias_method + +Style/Documentation: + Enabled: false + +Style/FrozenStringLiteralComment: + EnforcedStyle: never + +Style/OpenStructUse: + Enabled: false + +Style/StringLiterals: + EnforcedStyle: double_quotes + +Style/StringLiteralsInInterpolation: + EnforcedStyle: double_quotes + +Style/TernaryParentheses: + EnforcedStyle: require_parentheses diff --git a/lib/x/cgi.rb b/lib/x/cgi.rb index 2087fde..1e064bf 100644 --- a/lib/x/cgi.rb +++ b/lib/x/cgi.rb @@ -6,9 +6,5 @@ class CGI def self.escape(value) ::CGI.escape(value).gsub("+", "%20") end - - def self.escape_params(params) - params.map { |k, v| "#{k}=#{escape(v)}" }.join("&") - end end end diff --git a/lib/x/client.rb b/lib/x/client.rb index edf7411..2221977 100644 --- a/lib/x/client.rb +++ b/lib/x/client.rb @@ -38,11 +38,10 @@ def initialize(api_key: nil, api_key_secret: nil, access_token: nil, access_toke initialize_authenticator @base_url = base_url initialize_default_classes(default_array_class, default_object_class) - @connection = Connection.new(open_timeout: open_timeout, read_timeout: read_timeout, - write_timeout: write_timeout, debug_output: debug_output, proxy_url: proxy_url) + @connection = Connection.new(open_timeout: open_timeout, read_timeout: read_timeout, write_timeout: write_timeout, + debug_output: debug_output, proxy_url: proxy_url) @request_builder = RequestBuilder.new - @redirect_handler = RedirectHandler.new(connection: @connection, request_builder: @request_builder, - max_redirects: max_redirects) + @redirect_handler = RedirectHandler.new(connection: @connection, request_builder: @request_builder, max_redirects: max_redirects) @response_parser = ResponseParser.new end @@ -51,13 +50,11 @@ def get(endpoint, headers: {}, array_class: default_array_class, object_class: d end def post(endpoint, body = nil, headers: {}, array_class: default_array_class, object_class: default_object_class) - execute_request(:post, endpoint, body: body, headers: headers, array_class: array_class, - object_class: object_class) + execute_request(:post, endpoint, body: body, headers: headers, array_class: array_class, object_class: object_class) end def put(endpoint, body = nil, headers: {}, array_class: default_array_class, object_class: default_object_class) - execute_request(:put, endpoint, body: body, headers: headers, array_class: array_class, - object_class: object_class) + execute_request(:put, endpoint, body: body, headers: headers, array_class: array_class, object_class: object_class) end def delete(endpoint, headers: {}, array_class: default_array_class, object_class: default_object_class) @@ -119,11 +116,9 @@ def initialize_authenticator def execute_request(http_method, endpoint, body: nil, headers: {}, array_class: default_array_class, object_class: default_object_class) uri = URI.join(base_url, endpoint) - request = @request_builder.build(http_method: http_method, uri: uri, body: body, headers: headers, - authenticator: @authenticator) + request = @request_builder.build(http_method: http_method, uri: uri, body: body, headers: headers, authenticator: @authenticator) response = @connection.perform(request: request) - response = @redirect_handler.handle(response: response, request: request, base_url: base_url, - authenticator: @authenticator) + response = @redirect_handler.handle(response: response, request: request, base_url: base_url, authenticator: @authenticator) @response_parser.parse(response: response, array_class: array_class, object_class: object_class) end end diff --git a/lib/x/media_uploader.rb b/lib/x/media_uploader.rb index 661b585..4d5fca8 100644 --- a/lib/x/media_uploader.rb +++ b/lib/x/media_uploader.rb @@ -29,11 +29,10 @@ def chunked_upload(client:, file_path:, media_category:, media_type: infer_media media_category), boundary: SecureRandom.hex, chunk_size_mb: 8) validate!(file_path: file_path, media_category: media_category) upload_client = client.dup.tap { |c| c.base_url = "https://upload.twitter.com/1.1/" } - media = init(upload_client: upload_client, file_path: file_path, media_type: media_type, - media_category: media_category) + media = init(upload_client: upload_client, file_path: file_path, media_type: media_type, media_category: media_category) chunk_size = chunk_size_mb * BYTES_PER_MB - append(upload_client: upload_client, file_paths: split(file_path, chunk_size), media: media, - media_type: media_type, boundary: boundary) + append(upload_client: upload_client, file_paths: split(file_path, chunk_size), media: media, media_type: media_type, + boundary: boundary) upload_client.post("media/upload.json?command=FINALIZE&media_id=#{media["media_id"]}") end @@ -92,8 +91,7 @@ def append(upload_client:, file_paths:, media:, media_type:, boundary: SecureRan upload_body = construct_upload_body(file_path: file_path, media_type: media_type, boundary: boundary) query = "command=APPEND&media_id=#{media["media_id"]}&segment_index=#{index}" headers = {"Content-Type" => "multipart/form-data, boundary=#{boundary}"} - upload_chunk(upload_client: upload_client, query: query, upload_body: upload_body, file_path: file_path, - headers: headers) + upload_chunk(upload_client: upload_client, query: query, upload_body: upload_body, file_path: file_path, headers: headers) end end threads.each(&:join) diff --git a/lib/x/oauth_authenticator.rb b/lib/x/oauth_authenticator.rb index 979684d..9ec96c5 100644 --- a/lib/x/oauth_authenticator.rb +++ b/lib/x/oauth_authenticator.rb @@ -71,7 +71,7 @@ def hmac_signature(base_string) end def signature_base_string(method, url, params) - "#{method}&#{CGI.escape(url)}&#{CGI.escape(CGI.escape_params(params.sort))}" + "#{method}&#{CGI.escape(url)}&#{CGI.escape(URI.encode_www_form(params.sort))}" end def signing_key diff --git a/lib/x/request_builder.rb b/lib/x/request_builder.rb index af13467..31d8e5e 100644 --- a/lib/x/request_builder.rb +++ b/lib/x/request_builder.rb @@ -1,7 +1,6 @@ require "net/http" require "uri" require_relative "authenticator" -require_relative "cgi" require_relative "version" module X @@ -51,7 +50,7 @@ def add_headers(request:, headers:) end def escape_query_params(uri) - URI(uri).tap { |u| u.query = CGI.escape_params(URI.decode_www_form(u.query)) if u.query } + URI(uri).tap { |u| u.query = URI.encode_www_form(URI.decode_www_form(u.query)) if u.query } end end end diff --git a/sig/x.rbs b/sig/x.rbs index f471402..fc56e62 100644 --- a/sig/x.rbs +++ b/sig/x.rbs @@ -284,6 +284,5 @@ module X class CGI def self.escape: (String value) -> String - def self.escape_params: (Hash[String, String] | Array[[String, String]] params) -> String end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 25e200a..9254213 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -23,6 +23,15 @@ TEST_OAUTH_TIMESTAMP = Time.utc(1983, 11, 24).to_i.to_s TEST_MEDIA_ID = 1_234_567_890 +def test_oauth_credentials + { + api_key: TEST_API_KEY, + api_key_secret: TEST_API_KEY_SECRET, + access_token: TEST_ACCESS_TOKEN, + access_token_secret: TEST_ACCESS_TOKEN_SECRET + } +end + def test_oauth_params { "oauth_consumer_key" => TEST_API_KEY, diff --git a/test/x/cgi_test.rb b/test/x/cgi_test.rb index b854f00..a76ca5c 100644 --- a/test/x/cgi_test.rb +++ b/test/x/cgi_test.rb @@ -10,11 +10,5 @@ def test_escape assert_equal "foo%2Bbar", X::CGI.escape("foo+bar") assert_equal "%21%40%23%24", X::CGI.escape('!@#$') end - - def test_escape_params - assert_equal "key1=value1&key2=value2", X::CGI.escape_params([%w[key1 value1], %w[key2 value2]]) - assert_equal "foo=bar%20baz", X::CGI.escape_params({"foo" => "bar baz"}) - assert_equal "a=1%2F2&b=3%2B4", X::CGI.escape_params({"a" => "1/2", "b" => "3+4"}) - end end end diff --git a/test/x/client_initailization_test.rb b/test/x/client_initailization_test.rb index 0fd2fc9..a6c23d6 100644 --- a/test/x/client_initailization_test.rb +++ b/test/x/client_initailization_test.rb @@ -9,17 +9,8 @@ def setup @client = Client.new end - def oauth_credentials - { - api_key: TEST_API_KEY, - api_key_secret: TEST_API_KEY_SECRET, - access_token: TEST_ACCESS_TOKEN, - access_token_secret: TEST_ACCESS_TOKEN_SECRET - } - end - def test_initialize_oauth_credentials - client = Client.new(**oauth_credentials) + client = Client.new(**test_oauth_credentials) authenticator = client.instance_variable_get(:@authenticator) @@ -31,15 +22,15 @@ def test_initialize_oauth_credentials end def test_missing_oauth_credentials - oauth_credentials.each_key do |missing_credential| - client = Client.new(**oauth_credentials.except(missing_credential)) + test_oauth_credentials.each_key do |missing_credential| + client = Client.new(**test_oauth_credentials.except(missing_credential)) assert_instance_of Authenticator, client.instance_variable_get(:@authenticator) end end def test_setting_oauth_credentials - oauth_credentials.each do |credential, value| + test_oauth_credentials.each do |credential, value| @client.public_send(:"#{credential}=", value) assert_equal value, @client.public_send(credential) @@ -49,7 +40,7 @@ def test_setting_oauth_credentials end def test_setting_oauth_credentials_reinitializes_authenticator - oauth_credentials.each do |credential, value| + test_oauth_credentials.each do |credential, value| initialize_authenticator_called = false @client.stub :initialize_authenticator, -> { initialize_authenticator_called = true } do @client.public_send(:"#{credential}=", value) diff --git a/test/x/client_request_test.rb b/test/x/client_request_test.rb index a8a379c..af85ab6 100644 --- a/test/x/client_request_test.rb +++ b/test/x/client_request_test.rb @@ -29,9 +29,7 @@ def setup .to_return(body: '{"set": [1, 2, 2, 3]}', headers: {"Content-Type" => "application/json"}) ostruct = @client.public_send(http_method, "tweets", object_class: OpenStruct, array_class: Set) - assert_kind_of OpenStruct, ostruct - assert_kind_of Set, ostruct.set - assert_equal Set.new([1, 2, 3]), ostruct.set + assert_equal OpenStruct.new(set: Set.new([1, 2, 3])), ostruct end define_method :"test_#{http_method}_request_with_custom_response_objects_client_configuration" do @@ -40,9 +38,7 @@ def setup client = Client.new(default_object_class: OpenStruct, default_array_class: Set) ostruct = client.public_send(http_method, "tweets") - assert_kind_of OpenStruct, ostruct - assert_kind_of Set, ostruct.set - assert_equal Set.new([1, 2, 3]), ostruct.set + assert_equal OpenStruct.new(set: Set.new([1, 2, 3])), ostruct end end diff --git a/test/x/media_uploader_test.rb b/test/x/media_uploader_test.rb index da48090..8624be2 100644 --- a/test/x/media_uploader_test.rb +++ b/test/x/media_uploader_test.rb @@ -12,11 +12,11 @@ def setup end def test_upload + file_path = "test/sample_files/sample.jpg" stub_request(:post, "https://upload.twitter.com/1.1/media/upload.json?media_category=#{MediaUploader::TWEET_IMAGE}") .to_return(body: @media.to_json, headers: {"Content-Type" => "application/json"}) - result = MediaUploader.upload(client: @client, file_path: "test/sample_files/sample.jpg", - media_category: MediaUploader::TWEET_IMAGE, boundary: "AaB03x") + result = MediaUploader.upload(client: @client, file_path: file_path, media_category: MediaUploader::TWEET_IMAGE, boundary: "AaB03x") assert_equal TEST_MEDIA_ID, result["media_id"] end @@ -30,24 +30,24 @@ def test_chunked_upload stub_request(:post, "https://upload.twitter.com/1.1/media/upload.json?command=FINALIZE&media_id=#{TEST_MEDIA_ID}") .to_return(status: 201, headers: {"content-type" => "application/json"}, body: @media.to_json) - response = MediaUploader.chunked_upload(client: @client, file_path: file_path, - media_category: MediaUploader::TWEET_VIDEO, chunk_size_mb: (total_bytes - 1) / MediaUploader::BYTES_PER_MB.to_f) + response = MediaUploader.chunked_upload(client: @client, file_path: file_path, media_category: MediaUploader::TWEET_VIDEO, + chunk_size_mb: (total_bytes - 1) / MediaUploader::BYTES_PER_MB.to_f) assert_equal TEST_MEDIA_ID, response["media_id"] end def test_append_method file_path = "test/sample_files/sample.mp4" - chunk_paths = MediaUploader.send(:split, file_path, File.size(file_path) - 1) + file_paths = MediaUploader.send(:split, file_path, File.size(file_path) - 1) - chunk_paths.each_with_index do |_chunk_path, segment_index| + file_paths.each_with_index do |_chunk_path, segment_index| stub_request(:post, "https://upload.twitter.com/1.1/media/upload.json?command=APPEND&media_id=#{TEST_MEDIA_ID}&segment_index=#{segment_index}") .with(headers: {"Content-Type" => "multipart/form-data, boundary=AaB03x"}).to_return(status: 204) end - MediaUploader.send(:append, upload_client: @upload_client, file_paths: chunk_paths, media: @media, + MediaUploader.send(:append, upload_client: @upload_client, file_paths: file_paths, media: @media, media_type: "video/mp4", boundary: "AaB03x") - chunk_paths.each_with_index { |_, segment_index| assert_requested(:post, "https://upload.twitter.com/1.1/media/upload.json?command=APPEND&media_id=#{TEST_MEDIA_ID}&segment_index=#{segment_index}") } + file_paths.each_with_index { |_, segment_index| assert_requested(:post, "https://upload.twitter.com/1.1/media/upload.json?command=APPEND&media_id=#{TEST_MEDIA_ID}&segment_index=#{segment_index}") } end def test_await_processing @@ -102,38 +102,31 @@ def test_validate_with_invalid_media_category end def test_infer_media_type_for_gif - assert_equal MediaUploader::GIF_MIME_TYPE, - MediaUploader.send(:infer_media_type, "test/sample_files/sample.gif", "tweet_gif") + assert_equal MediaUploader::GIF_MIME_TYPE, MediaUploader.send(:infer_media_type, "test/sample_files/sample.gif", "tweet_gif") end def test_infer_media_type_for_jpg - assert_equal MediaUploader::JPEG_MIME_TYPE, - MediaUploader.send(:infer_media_type, "test/sample_files/sample.jpg", "tweet_image") + assert_equal MediaUploader::JPEG_MIME_TYPE, MediaUploader.send(:infer_media_type, "test/sample_files/sample.jpg", "tweet_image") end def test_infer_media_type_for_mp4 - assert_equal MediaUploader::MP4_MIME_TYPE, - MediaUploader.send(:infer_media_type, "test/sample_files/sample.mp4", "tweet_video") + assert_equal MediaUploader::MP4_MIME_TYPE, MediaUploader.send(:infer_media_type, "test/sample_files/sample.mp4", "tweet_video") end def test_infer_media_type_for_png - assert_equal MediaUploader::PNG_MIME_TYPE, - MediaUploader.send(:infer_media_type, "test/sample_files/sample.png", "tweet_image") + assert_equal MediaUploader::PNG_MIME_TYPE, MediaUploader.send(:infer_media_type, "test/sample_files/sample.png", "tweet_image") end def test_infer_media_type_for_srt - assert_equal MediaUploader::SUBRIP_MIME_TYPE, - MediaUploader.send(:infer_media_type, "test/sample_files/sample.srt", "subtitles") + assert_equal MediaUploader::SUBRIP_MIME_TYPE, MediaUploader.send(:infer_media_type, "test/sample_files/sample.srt", "subtitles") end def test_infer_media_type_for_webp - assert_equal MediaUploader::WEBP_MIME_TYPE, - MediaUploader.send(:infer_media_type, "test/sample_files/sample.webp", "tweet_image") + assert_equal MediaUploader::WEBP_MIME_TYPE, MediaUploader.send(:infer_media_type, "test/sample_files/sample.webp", "tweet_image") end def test_infer_media_type_with_default - assert_equal MediaUploader::DEFAULT_MIME_TYPE, - MediaUploader.send(:infer_media_type, "test/sample_files/sample.unknown", "tweet_image") + assert_equal MediaUploader::DEFAULT_MIME_TYPE, MediaUploader.send(:infer_media_type, "test/sample_files/sample.dne", "tweet_image") end end end diff --git a/test/x/redirect_handler_test.rb b/test/x/redirect_handler_test.rb index a65bc34..d128880 100644 --- a/test/x/redirect_handler_test.rb +++ b/test/x/redirect_handler_test.rb @@ -18,125 +18,125 @@ def test_initialize_with_defaults end def test_handle_with_no_redirects - original_request = Net::HTTP::Get.new("/some_path") + request = Net::HTTP::Get.new("/some_path") response = Net::HTTPSuccess.new("1.1", "200", "OK") - assert_equal(response, @redirect_handler.handle(response: response, request: original_request, base_url: "http://example.com")) + assert_equal(response, @redirect_handler.handle(response: response, request: request, base_url: "http://example.com")) end def test_handle_with_one_redirect authenticator = BearerTokenAuthenticator.new(bearer_token: TEST_BEARER_TOKEN) - original_request = Net::HTTP::Get.new("/") + request = Net::HTTP::Get.new("/") stub_request(:get, "http://www.example.com/").with(headers: {"Authorization" => /Bearer #{TEST_BEARER_TOKEN}/o}) response = Net::HTTPFound.new("1.1", "302", "Found") response["Location"] = "http://www.example.com" - @redirect_handler.handle(response: response, request: original_request, base_url: "http://example.com", + @redirect_handler.handle(response: response, request: request, base_url: "http://example.com", authenticator: authenticator) assert_requested :get, "http://www.example.com" end def test_handle_with_two_redirects - original_request = Net::HTTP::Delete.new("/") + request = Net::HTTP::Delete.new("/") stub_request(:delete, "http://example.com/2").to_return(status: 307, headers: {"Location" => "http://example.com/3"}) stub_request(:delete, "http://example.com/3") response = Net::HTTPFound.new("1.1", "307", "Found") response["Location"] = "http://example.com/2" - @redirect_handler.handle(response: response, request: original_request, base_url: "http://example.com") + @redirect_handler.handle(response: response, request: request, base_url: "http://example.com") assert_requested :delete, "http://example.com/2" assert_requested :delete, "http://example.com/3" end def test_handle_with_relative_url - original_request = Net::HTTP::Get.new("/some_path") + request = Net::HTTP::Get.new("/some_path") stub_request(:get, "http://example.com/some_relative_path") response = Net::HTTPFound.new("1.1", "302", "Found") response["Location"] = "/some_relative_path" - @redirect_handler.handle(response: response, request: original_request, base_url: "http://example.com") + @redirect_handler.handle(response: response, request: request, base_url: "http://example.com") assert_requested :get, "http://example.com/some_relative_path" end def test_handle_with_301_moved_permanently - original_request = Net::HTTP::Get.new("/some_path") + request = Net::HTTP::Get.new("/some_path") stub_request(:get, "http://example.com/new_path") response = Net::HTTPMovedPermanently.new("1.1", "301", "Moved Permanently") response["Location"] = "http://example.com/new_path" - @redirect_handler.handle(response: response, request: original_request, base_url: "http://example.com") + @redirect_handler.handle(response: response, request: request, base_url: "http://example.com") assert_requested :get, "http://example.com/new_path" end def test_handle_with_302_found - original_request = Net::HTTP::Get.new("/some_path") + request = Net::HTTP::Get.new("/some_path") stub_request(:get, "http://example.com/temp_path") response = Net::HTTPFound.new("1.1", "302", "Found") response["Location"] = "http://example.com/temp_path" - @redirect_handler.handle(response: response, request: original_request, base_url: "http://example.com") + @redirect_handler.handle(response: response, request: request, base_url: "http://example.com") assert_requested :get, "http://example.com/temp_path" end def test_handle_with_303_see_other - original_request = Net::HTTP::Post.new("/some_path") + request = Net::HTTP::Post.new("/some_path") stub_request(:post, "http://example.com/some_path") stub_request(:get, "http://example.com/other_path") response = Net::HTTPSeeOther.new("1.1", "303", "See Other") response["Location"] = "http://example.com/other_path" - @redirect_handler.handle(response: response, request: original_request, base_url: "http://example.com") + @redirect_handler.handle(response: response, request: request, base_url: "http://example.com") assert_requested :get, "http://example.com/other_path" end def test_handle_with_307_temporary_redirect - original_request = Net::HTTP::Post.new("/some_path") - original_request.body = "request_body" + request = Net::HTTP::Post.new("/some_path") + request.body = "request_body" stub_request(:post, "http://example.com/temp_path") response = Net::HTTPTemporaryRedirect.new("1.1", "307", "Temporary Redirect") response["Location"] = "http://example.com/temp_path" - @redirect_handler.handle(response: response, request: original_request, base_url: "http://example.com") + @redirect_handler.handle(response: response, request: request, base_url: "http://example.com") assert_requested :post, "http://example.com/temp_path", body: "request_body" end def test_handle_with_308_permanent_redirect - original_request = Net::HTTP::Post.new("/some_path") - original_request.body = "request_body" + request = Net::HTTP::Post.new("/some_path") + request.body = "request_body" stub_request(:post, "http://example.com/new_path") response = Net::HTTPPermanentRedirect.new("1.1", "308", "Permanent Redirect") response["Location"] = "http://example.com/new_path" - @redirect_handler.handle(response: response, request: original_request, base_url: "http://example.com") + @redirect_handler.handle(response: response, request: request, base_url: "http://example.com") assert_requested :post, "http://example.com/new_path", body: "request_body" end def test_handle_with_too_many_redirects - original_request = Net::HTTP::Get.new("/some_path") + request = Net::HTTP::Get.new("/some_path") stub_request(:get, "http://example.com/some_path").to_return(status: 302, headers: {"Location" => "http://example.com/some_path"}) response = Net::HTTPFound.new("1.1", "302", "Found") response["Location"] = "http://example.com/some_path" e = assert_raises(TooManyRedirects) do - @redirect_handler.handle(response: response, request: original_request, base_url: "http://example.com") + @redirect_handler.handle(response: response, request: request, base_url: "http://example.com") end assert_equal "Too many redirects", e.message diff --git a/test/x/response_parser_test.rb b/test/x/response_parser_test.rb index 4a565c2..3d19df9 100644 --- a/test/x/response_parser_test.rb +++ b/test/x/response_parser_test.rb @@ -65,7 +65,8 @@ def test_error_with_title_only def test_error_with_detail_only stub_request(:get, @uri.to_s) - .to_return(status: [400, "Bad Request"], body: '{"detail": "Something went wrong"}', headers: {"Content-Type" => "application/json"}) + .to_return(status: [400, "Bad Request"], body: '{"detail": "Something went wrong"}', + headers: {"Content-Type" => "application/json"}) exception = assert_raises(BadRequest) { @response_parser.parse(response: response) } assert_equal "Bad Request", exception.message @@ -73,7 +74,8 @@ def test_error_with_detail_only def test_error_with_title_and_detail_error_message stub_request(:get, @uri.to_s) - .to_return(status: 400, body: '{"title": "Some Error", "detail": "Something went wrong"}', headers: {"Content-Type" => "application/json"}) + .to_return(status: 400, + body: '{"title": "Some Error", "detail": "Something went wrong"}', headers: {"Content-Type" => "application/json"}) exception = assert_raises(BadRequest) { @response_parser.parse(response: response) } assert_equal("Some Error: Something went wrong", exception.message) @@ -89,7 +91,8 @@ def test_error_with_error_message def test_error_with_errors_array_message stub_request(:get, @uri.to_s) - .to_return(status: 400, body: '{"errors": [{"message": "Some Error"}, {"message": "Another Error"}]}', headers: {"Content-Type" => "application/json"}) + .to_return(status: 400, + body: '{"errors": [{"message": "Some Error"}, {"message": "Another Error"}]}', headers: {"Content-Type" => "application/json"}) exception = assert_raises(BadRequest) { @response_parser.parse(response: response) } assert_equal("Some Error, Another Error", exception.message) @@ -97,7 +100,8 @@ def test_error_with_errors_array_message def test_error_with_errors_message stub_request(:get, @uri.to_s) - .to_return(status: 400, body: '{"errors": {"message": "Some Error"}}', headers: {"Content-Type" => "application/json"}) + .to_return(status: 400, + body: '{"errors": {"message": "Some Error"}}', headers: {"Content-Type" => "application/json"}) exception = assert_raises(BadRequest) { @response_parser.parse(response: response) } assert_empty exception.message