From 2b55e6a148729cd597f5d245618567e232c66b43 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Sat, 9 Jul 2022 16:07:16 +0300 Subject: [PATCH] Fix RSpec 4 shared context inclusion Starting from RSpec 4, the implicit shared context inclusion, when a shared context would have been included to an example if the example has matching metadata, is not the case anymore. See: - https://github.com/rspec/rspec-core/pull/2834 - https://github.com/rspec/rspec-core/issues/2832 - https://github.com/rspec/rspec-core/pull/2878 --- spec/rubocop/cli/autocorrect_spec.rb | 4 +++- spec/spec_helper.rb | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/rubocop/cli/autocorrect_spec.rb b/spec/rubocop/cli/autocorrect_spec.rb index a709ef369..6740c23f8 100644 --- a/spec/rubocop/cli/autocorrect_spec.rb +++ b/spec/rubocop/cli/autocorrect_spec.rb @@ -1,8 +1,10 @@ # frozen_string_literal: true -RSpec.describe 'RuboCop::CLI --autocorrect', :isolated_environment do # rubocop:disable RSpec/DescribeClass +RSpec.describe 'RuboCop::CLI --autocorrect' do # rubocop:disable RSpec/DescribeClass subject(:cli) { RuboCop::CLI.new } + include_context 'isolated environment' + include_context 'when cli spec behavior' context 'when corrects `RSpec/Capybara/CurrentPathExpectation` with ' \ diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c5feb6839..c4f4d7deb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -34,6 +34,10 @@ module SpecHelper config.raise_on_warning = true config.include(ExpectOffense) + + config.include_context 'with default RSpec/Language config', :config + config.include_context 'config', :config + config.include_context 'smoke test', type: :cop_spec end $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))