Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .generator/src/generator/templates/api_client.j2
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ module {{ module_name }}
:http_proxyaddr => @config.http_proxyaddr,
:http_proxyport => @config.http_proxyport,
:http_proxyuser => @config.http_proxyuser,
:http_proxypass => @config.http_proxypass
:http_proxypass => @config.http_proxypass,
:query_string_normalizer => HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER
}

req_opts[:pem] = File.read(@config.cert_file) if @config.cert_file
Expand Down
5 changes: 3 additions & 2 deletions features/step_definitions/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require_relative '../scenarios_model_mapping'

SLEEP_AFTER_REQUEST = ENV.has_key?("SLEEP_AFTER_REQUEST") ? ENV["SLEEP_AFTER_REQUEST"].to_i : 0
WebMock::Config.instance.query_values_notation = :flat_array

module APIWorld
def api
Expand Down Expand Up @@ -100,7 +101,7 @@ def relative_time(iso)
return ret.rfc3339(3) if iso
return ret.to_i
end
return nil
nil
}
end

Expand Down Expand Up @@ -221,7 +222,7 @@ def build_given(api_version, operation)
def model_builder(param, obj)
model = ScenariosModelMappings["v#{@api_version}.#{@operation_id}"][param]
if model == 'File'
return File.open(File.join(__dir__, "..", "v" + @api_version, obj))
return File.open(File.join(__dir__, "..", "v" + @api_version, obj))
end
@api_client.convert_to_type(obj, model, "V#{@api_version}")
end
Expand Down
9 changes: 8 additions & 1 deletion features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ def use_real_time?
c.register_request_matcher :safe_headers do |r1, r2|
r1.headers.slice(*filtered_headers) == r2.headers.slice(*filtered_headers)
end
c.register_request_matcher :ignore_query_param_ordering do |r1, r2|
uri1 = URI(r1.uri)
uri2 = URI(r2.uri)
query1 = CGI.parse(uri1.query || '').transform_values(&:sort)
query2 = CGI.parse(uri2.query || '').transform_values(&:sort)
query1 == query2
end
c.default_cassette_options = {
:record_on_error => false,
:match_requests_on => [:method, :host, :safe_path, :query, :body_as_json, :safe_headers],
:match_requests_on => [:method, :host, :safe_path, :ignore_query_param_ordering, :body_as_json, :safe_headers],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Suggested change
:match_requests_on => [:method, :host, :safe_path, :ignore_query_param_ordering, :body_as_json, :safe_headers],
:match_requests_on => %i[method host safe_path ignore_query_param_ordering body_as_json safe_headers],
Consider using the %i syntax instead (...read more)

The rule "Prefer %i to the literal array syntax" is a guideline that encourages the use of the %i syntax for arrays of symbols. This is a part of the Ruby style guide that aims to promote conciseness and readability.

Symbols are immutable, reusable objects often used in Ruby instead of strings when the value does not need to be changed. When declaring an array of symbols, using the %i syntax can make your code cleaner and easier to read.

To adhere to this rule, instead of declaring an array of symbols using the literal array syntax like [:foo, :bar, :baz], use the %i syntax like %i[foo bar baz]. It's a good practice to consistently use %i for arrays of symbols as it enhances code readability and maintainability.

View in Datadog  Leave us feedback  Documentation

}
c.allow_http_connections_when_no_cassette = true
RecordMode.send(ENV["RECORD"] || "false", c)
Expand Down
Loading