Class: RuboCop::Cop::Betterment::ServerErrorAssertion
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Betterment::ServerErrorAssertion
- Defined in:
- lib/rubocop/cop/betterment/server_error_assertion.rb
Overview
Checks the status passed to have_http_status
If a number, enforces that it doesn't start with 5. If a symbol or a string, enforces that it's not one of:
- internal_server_error
- not_implemented
- bad_gateway
- service_unavailable
- gateway_timeout
- http_version_not_supported
- insufficient_storage
- not_extended
Constant Summary collapse
- MSG =
'Do not assert on 5XX statuses. Use a semantic status (e.g., 403, 422, etc.) or treat them as bugs (omit tests).'- BAD_STATUSES =
%i( internal_server_error not_implemented bad_gateway service_unavailable gateway_timeout http_version_not_supported insufficient_storage not_extended ).freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
55 56 57 58 59 |
# File 'lib/rubocop/cop/betterment/server_error_assertion.rb', line 55 def on_send(node) return unless offensive_node?(node) add_offense(node) end |