lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb in rubocop-rspec-2.27.1 vs lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb in rubocop-rspec-2.28.0
- old
+ new
@@ -2,42 +2,26 @@
module RuboCop
module Cop
module RSpec
module Rails
- # Checks that tests use RSpec `before` hook over Rails `setup` method.
- #
- # @example
- # # bad
- # setup do
- # allow(foo).to receive(:bar)
- # end
- #
- # # good
- # before do
- # allow(foo).to receive(:bar)
- # end
- #
- class AvoidSetupHook < Base
- extend AutoCorrector
-
- MSG = 'Use `before` instead of `setup`.'
-
- # @!method setup_call(node)
- def_node_matcher :setup_call, <<~PATTERN
- (block
- $(send nil? :setup)
- (args) _)
- PATTERN
-
- def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
- setup_call(node) do |setup|
- add_offense(node) do |corrector|
- corrector.replace setup, 'before'
- end
- end
- end
- end
+ # @!parse
+ # # Checks that tests use RSpec `before` hook over Rails `setup`
+ # # method.
+ # #
+ # # @example
+ # # # bad
+ # # setup do
+ # # allow(foo).to receive(:bar)
+ # # end
+ # #
+ # # # good
+ # # before do
+ # # allow(foo).to receive(:bar)
+ # # end
+ # #
+ # class AvoidSetupHook < RuboCop::Cop::RSpecRails::Base; end
+ AvoidSetupHook = ::RuboCop::Cop::RSpecRails::AvoidSetupHook
end
end
end
end