Class: RuboCop::Cop::Workit::ComitteeAssertSchemaConfirm
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Workit::ComitteeAssertSchemaConfirm
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/workit/comittee_assert_schema_confirm.rb
Overview
Check for not pass expected response status code to check it against the corresponding schema explicitly.
Constant Summary collapse
- MSG =
"Pass expected response status code to check it against the corresponding schema explicitly."
- RESTRICT_ON_SEND =
%i[assert_schema_conform assert_response_schema_confirm].freeze
Instance Method Summary collapse
Instance Method Details
#have_http_status(node) ⇒ Object
32 33 34 |
# File 'lib/rubocop/cop/workit/comittee_assert_schema_confirm.rb', line 32 def_node_search :have_http_status, <<~PATTERN $(send nil? :have_http_status (:int $_)) PATTERN |
#on_send(node) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rubocop/cop/workit/comittee_assert_schema_confirm.rb', line 36 def on_send(node) return if node.arguments? have_http_status(node.parent) do |child_node, value| add_offense(node) do |corrector| corrector.remove(range_by_whole_lines(child_node.parent.loc.expression, include_final_newline: true)) corrector.insert_after(node, "(#{value})") end end end |