Sha256: a670c4328044ac4180c3ef18133b60f86b0b051f91c24e9ac34caefc5ecec7e7
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Committee # Check if the status code is specified as an argument to the method of the Committee # where the expected response status code is required. # # @example # # bad # it 'something' do # subject # expect(response).to have_http_status 400 # assert_schema_conform # end # # # good # it 'something' do # subject # assert_schema_conform(400) # end # class UnspecifiedExpectedStatus < Base include RangeHelp extend AutoCorrector MSG = "Specify the HTTP status code of the expected response as an argument." RESTRICT_ON_SEND = %i[assert_schema_conform assert_response_schema_confirm].freeze # @!method have_http_status(node) def_node_search :have_http_status, <<~PATTERN (send nil? :have_http_status (:int $_)) PATTERN def on_send(node) return if node.arguments? have_http_status(node.parent) do |status| return autocorrect(node, status) end add_offense(node) end private def autocorrect(node, status) add_offense(node) do |corrector| corrector.insert_after(node, "(#{status})") end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-committee-0.1.1 | lib/rubocop/cop/committee/unspecified_expected_status.rb |
rubocop-committee-0.1.0 | lib/rubocop/cop/committee/unspecified_expected_status.rb |