class RuboCop::Cop::Netlify::RequestTestsParamEncoding
This cop enforces the test to use `as:` option for encoding the request with a content type.
@example
# bad post "api/v1/user", params: { name: "Esteban" } # good post "api/v1/user", params: { name: "Esteban" }, as: :json
Constants
- MSG
Public Instance Methods
on_send(node)
click to toggle source
# File lib/rubocop/cop/netlify/request_tests_param_encoding.rb, line 30 def on_send(node) request_method(node) do |http_method, option_pairs| params = option_pairs.detect { |pair| has_params?(pair) } as = option_pairs.detect { |pair| has_as?(pair) } if params && !as message = format(MSG, http_method: http_method) add_offense(node, message: message) end end end