diff --git a/spec/rubocop/cop/thread_safety/mutable_class_instance_variable_spec.rb b/spec/rubocop/cop/thread_safety/mutable_class_instance_variable_spec.rb index bc6346b..564b389 100644 --- a/spec/rubocop/cop/thread_safety/mutable_class_instance_variable_spec.rb +++ b/spec/rubocop/cop/thread_safety/mutable_class_instance_variable_spec.rb @@ -282,10 +282,16 @@ def some_method it_behaves_like 'mutable objects', %("\#{a}") end - context 'when the frozen_string_literal comment is true', unsupported_on: :prism do - let(:prefix) { "# frozen_string_literal: true\n#{super()}" } + context 'when the frozen_string_literal comment is true' do + context 'with Ruby 2.7', unsupported_on: :prism do + let(:prefix) { "# frozen_string_literal: true\n#{super()}" } - it_behaves_like 'immutable objects', %("\#{a}") + it_behaves_like 'immutable objects', %("\#{a}") + end + + context 'with Ruby 3', :ruby30 do + it_behaves_like 'mutable objects', %("\#{a}") + end end context 'when the frozen_string_literal comment is false' do @@ -605,10 +611,18 @@ def assignment? it_behaves_like 'mutable objects', %("\#{a}") end - context 'when the frozen_string_literal comment is true', unsupported_on: :prism do - let(:prefix) { "# frozen_string_literal: true\n#{super()}" } + context 'when the frozen_string_literal comment is true' do + context 'with Ruby 2.7', unsupported_on: :prism do + let(:prefix) { "# frozen_string_literal: true\n#{super()}" } - it_behaves_like 'immutable objects', %("\#{a}") + it_behaves_like 'immutable objects', %("\#{a}") + end + + context 'with Ruby 3', :ruby30 do + let(:prefix) { "# frozen_string_literal: true\n#{super()}" } + + it_behaves_like 'mutable objects', %("\#{a}") + end end context 'when the frozen_string_literal comment is false' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index be1363f..0eaadf4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -46,4 +46,11 @@ config.order = :random Kernel.srand config.seed + + config.include_context 'ruby 2.7', :ruby27 + config.include_context 'ruby 3.0', :ruby30 + config.include_context 'ruby 3.1', :ruby31 + config.include_context 'ruby 3.2', :ruby32 + config.include_context 'ruby 3.3', :ruby33 + config.include_context 'ruby 3.4', :ruby34 end