Skip to content

Commit

Permalink
Add MRI3 tests for MutableClassInstanceVariable cop
Browse files Browse the repository at this point in the history
  • Loading branch information
viralpraxis committed Sep 23, 2024
1 parent f6a2a34 commit 7a47d02
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7a47d02

Please sign in to comment.