lib/rubocop/cop/rspec/before_after_all.rb in rubocop-rspec-2.25.0 vs lib/rubocop/cop/rspec/before_after_all.rb in rubocop-rspec-2.26.0

- old
+ new

@@ -1,26 +1,20 @@ # frozen_string_literal: true module RuboCop module Cop module RSpec - # Check that before/after(:all) isn't being used. + # Check that before/after(:all/:context) isn't being used. # # @example - # # bad - # # - # # Faster but risk of state leaking between examples - # # + # # bad - Faster but risk of state leaking between examples # describe MyClass do # before(:all) { Widget.create } - # after(:all) { Widget.delete_all } + # after(:context) { Widget.delete_all } # end # - # # good - # # - # # Slower but examples are properly isolated - # # + # # good - Slower but examples are properly isolated # describe MyClass do # before(:each) { Widget.create } # after(:each) { Widget.delete_all } # end # @@ -28,14 +22,14 @@ MSG = 'Beware of using `%<hook>s` as it may cause state to leak ' \ 'between tests. If you are using `rspec-rails`, and ' \ '`use_transactional_fixtures` is enabled, then records created ' \ 'in `%<hook>s` are not automatically rolled back.' - RESTRICT_ON_SEND = %i[before after].freeze + RESTRICT_ON_SEND = Set[:before, :after].freeze # @!method before_or_after_all(node) - def_node_matcher :before_or_after_all, <<-PATTERN - $(send _ {:before :after} (sym {:all :context})) + def_node_matcher :before_or_after_all, <<~PATTERN + $(send _ RESTRICT_ON_SEND (sym {:all :context})) PATTERN def on_send(node) before_or_after_all(node) do |hook| add_offense(