lib/rubocop/cop/rspec/rails/have_http_status.rb in rubocop-rspec-2.15.0 vs lib/rubocop/cop/rspec/rails/have_http_status.rb in rubocop-rspec-2.16.0
- old
+ new
@@ -11,23 +11,26 @@
# expect(response.status).to be(200)
#
# # good
# expect(response).to have_http_status(200)
#
- class HaveHttpStatus < Base
+ class HaveHttpStatus < ::RuboCop::Cop::Base
extend AutoCorrector
MSG =
'Prefer `expect(response).%<to>s have_http_status(%<status>i)` ' \
'over `expect(response.status).%<to>s %<match>s`.'
+ RUNNERS = %i[to to_not not_to].to_set
+ RESTRICT_ON_SEND = RUNNERS
+
# @!method match_status(node)
def_node_matcher :match_status, <<-PATTERN
(send
(send nil? :expect
$(send (send nil? :response) :status)
)
- $#Runners.all
+ $RUNNERS
$(send nil? {:be :eq :eql :equal} (int $_))
)
PATTERN
def on_send(node)