Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RuboCop::MagicComment#valid_shareable_constant_value? #9598

Merged
merged 1 commit into from Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/fix_fix_valid_shareable_constant_value.md
@@ -0,0 +1 @@
* [#9598](https://github.com/rubocop/rubocop/pull/9598): Fix RuboCop::MagicComment#valid_shareable_constant_value?. ([@kachick][])
2 changes: 1 addition & 1 deletion lib/rubocop/magic_comment.rb
Expand Up @@ -47,7 +47,7 @@ def valid_literal_value?
end

def valid_shareable_constant_value?
%w[none literal experimental_everything experimental_copy].include?(shareable_constant_values)
%w[none literal experimental_everything experimental_copy].include?(shareable_constant_value)
end

# Was a magic comment for the frozen string literal found?
Expand Down
40 changes: 40 additions & 0 deletions spec/rubocop/magic_comment_spec.rb
Expand Up @@ -151,4 +151,44 @@
include_examples 'magic comment',
'# vim:fileencoding=utf-8',
encoding: nil

describe '#valid_shareable_constant_value?' do
subject { described_class.parse(comment).valid_shareable_constant_value? }

context 'when given comment specified as `none`' do
let(:comment) { '# shareable_constant_value: none' }

it { is_expected.to eq(true) }
end

context 'when given comment specified as `literal`' do
let(:comment) { '# shareable_constant_value: literal' }

it { is_expected.to eq(true) }
end

context 'when given comment specified as `experimental_everything`' do
let(:comment) { '# shareable_constant_value: experimental_everything' }

it { is_expected.to eq(true) }
end

context 'when given comment specified as `experimental_copy`' do
let(:comment) { '# shareable_constant_value: experimental_copy' }

it { is_expected.to eq(true) }
end

context 'when given comment specified as unknown value' do
let(:comment) { '# shareable_constant_value: unknown' }

it { is_expected.to eq(false) }
end

context 'when given comment is not specified' do
let(:comment) { '' }

it { is_expected.to eq(false) }
end
end
end